aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/golang/protobuf/ptypes
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/golang/protobuf/ptypes')
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/any.go141
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/any/any.pb.go191
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/any/any.proto149
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/doc.go35
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/duration.go102
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go159
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/duration/duration.proto117
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/timestamp.go134
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go175
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto133
10 files changed, 1336 insertions, 0 deletions
diff --git a/vendor/github.com/golang/protobuf/ptypes/any.go b/vendor/github.com/golang/protobuf/ptypes/any.go
new file mode 100644
index 0000000..70276e8
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/any.go
@@ -0,0 +1,141 @@
1// Go support for Protocol Buffers - Google's data interchange format
2//
3// Copyright 2016 The Go Authors. All rights reserved.
4// https://github.com/golang/protobuf
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16// * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32package ptypes
33
34// This file implements functions to marshal proto.Message to/from
35// google.protobuf.Any message.
36
37import (
38 "fmt"
39 "reflect"
40 "strings"
41
42 "github.com/golang/protobuf/proto"
43 "github.com/golang/protobuf/ptypes/any"
44)
45
46const googleApis = "type.googleapis.com/"
47
48// AnyMessageName returns the name of the message contained in a google.protobuf.Any message.
49//
50// Note that regular type assertions should be done using the Is
51// function. AnyMessageName is provided for less common use cases like filtering a
52// sequence of Any messages based on a set of allowed message type names.
53func AnyMessageName(any *any.Any) (string, error) {
54 if any == nil {
55 return "", fmt.Errorf("message is nil")
56 }
57 slash := strings.LastIndex(any.TypeUrl, "/")
58 if slash < 0 {
59 return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl)
60 }
61 return any.TypeUrl[slash+1:], nil
62}
63
64// MarshalAny takes the protocol buffer and encodes it into google.protobuf.Any.
65func MarshalAny(pb proto.Message) (*any.Any, error) {
66 value, err := proto.Marshal(pb)
67 if err != nil {
68 return nil, err
69 }
70 return &any.Any{TypeUrl: googleApis + proto.MessageName(pb), Value: value}, nil
71}
72
73// DynamicAny is a value that can be passed to UnmarshalAny to automatically
74// allocate a proto.Message for the type specified in a google.protobuf.Any
75// message. The allocated message is stored in the embedded proto.Message.
76//
77// Example:
78//
79// var x ptypes.DynamicAny
80// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
81// fmt.Printf("unmarshaled message: %v", x.Message)
82type DynamicAny struct {
83 proto.Message
84}
85
86// Empty returns a new proto.Message of the type specified in a
87// google.protobuf.Any message. It returns an error if corresponding message
88// type isn't linked in.
89func Empty(any *any.Any) (proto.Message, error) {
90 aname, err := AnyMessageName(any)
91 if err != nil {
92 return nil, err
93 }
94
95 t := proto.MessageType(aname)
96 if t == nil {
97 return nil, fmt.Errorf("any: message type %q isn't linked in", aname)
98 }
99 return reflect.New(t.Elem()).Interface().(proto.Message), nil
100}
101
102// UnmarshalAny parses the protocol buffer representation in a google.protobuf.Any
103// message and places the decoded result in pb. It returns an error if type of
104// contents of Any message does not match type of pb message.
105//
106// pb can be a proto.Message, or a *DynamicAny.
107func UnmarshalAny(any *any.Any, pb proto.Message) error {
108 if d, ok := pb.(*DynamicAny); ok {
109 if d.Message == nil {
110 var err error
111 d.Message, err = Empty(any)
112 if err != nil {
113 return err
114 }
115 }
116 return UnmarshalAny(any, d.Message)
117 }
118
119 aname, err := AnyMessageName(any)
120 if err != nil {
121 return err
122 }
123
124 mname := proto.MessageName(pb)
125 if aname != mname {
126 return fmt.Errorf("mismatched message type: got %q want %q", aname, mname)
127 }
128 return proto.Unmarshal(any.Value, pb)
129}
130
131// Is returns true if any value contains a given message type.
132func Is(any *any.Any, pb proto.Message) bool {
133 // The following is equivalent to AnyMessageName(any) == proto.MessageName(pb),
134 // but it avoids scanning TypeUrl for the slash.
135 if any == nil {
136 return false
137 }
138 name := proto.MessageName(pb)
139 prefix := len(any.TypeUrl) - len(name)
140 return prefix >= 1 && any.TypeUrl[prefix-1] == '/' && any.TypeUrl[prefix:] == name
141}
diff --git a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go
new file mode 100644
index 0000000..e3c56d3
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go
@@ -0,0 +1,191 @@
1// Code generated by protoc-gen-go. DO NOT EDIT.
2// source: google/protobuf/any.proto
3
4package any // import "github.com/golang/protobuf/ptypes/any"
5
6import proto "github.com/golang/protobuf/proto"
7import fmt "fmt"
8import math "math"
9
10// Reference imports to suppress errors if they are not otherwise used.
11var _ = proto.Marshal
12var _ = fmt.Errorf
13var _ = math.Inf
14
15// This is a compile-time assertion to ensure that this generated file
16// is compatible with the proto package it is being compiled against.
17// A compilation error at this line likely means your copy of the
18// proto package needs to be updated.
19const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
20
21// `Any` contains an arbitrary serialized protocol buffer message along with a
22// URL that describes the type of the serialized message.
23//
24// Protobuf library provides support to pack/unpack Any values in the form
25// of utility functions or additional generated methods of the Any type.
26//
27// Example 1: Pack and unpack a message in C++.
28//
29// Foo foo = ...;
30// Any any;
31// any.PackFrom(foo);
32// ...
33// if (any.UnpackTo(&foo)) {
34// ...
35// }
36//
37// Example 2: Pack and unpack a message in Java.
38//
39// Foo foo = ...;
40// Any any = Any.pack(foo);
41// ...
42// if (any.is(Foo.class)) {
43// foo = any.unpack(Foo.class);
44// }
45//
46// Example 3: Pack and unpack a message in Python.
47//
48// foo = Foo(...)
49// any = Any()
50// any.Pack(foo)
51// ...
52// if any.Is(Foo.DESCRIPTOR):
53// any.Unpack(foo)
54// ...
55//
56// Example 4: Pack and unpack a message in Go
57//
58// foo := &pb.Foo{...}
59// any, err := ptypes.MarshalAny(foo)
60// ...
61// foo := &pb.Foo{}
62// if err := ptypes.UnmarshalAny(any, foo); err != nil {
63// ...
64// }
65//
66// The pack methods provided by protobuf library will by default use
67// 'type.googleapis.com/full.type.name' as the type URL and the unpack
68// methods only use the fully qualified type name after the last '/'
69// in the type URL, for example "foo.bar.com/x/y.z" will yield type
70// name "y.z".
71//
72//
73// JSON
74// ====
75// The JSON representation of an `Any` value uses the regular
76// representation of the deserialized, embedded message, with an
77// additional field `@type` which contains the type URL. Example:
78//
79// package google.profile;
80// message Person {
81// string first_name = 1;
82// string last_name = 2;
83// }
84//
85// {
86// "@type": "type.googleapis.com/google.profile.Person",
87// "firstName": <string>,
88// "lastName": <string>
89// }
90//
91// If the embedded message type is well-known and has a custom JSON
92// representation, that representation will be embedded adding a field
93// `value` which holds the custom JSON in addition to the `@type`
94// field. Example (for message [google.protobuf.Duration][]):
95//
96// {
97// "@type": "type.googleapis.com/google.protobuf.Duration",
98// "value": "1.212s"
99// }
100//
101type Any struct {
102 // A URL/resource name whose content describes the type of the
103 // serialized protocol buffer message.
104 //
105 // For URLs which use the scheme `http`, `https`, or no scheme, the
106 // following restrictions and interpretations apply:
107 //
108 // * If no scheme is provided, `https` is assumed.
109 // * The last segment of the URL's path must represent the fully
110 // qualified name of the type (as in `path/google.protobuf.Duration`).
111 // The name should be in a canonical form (e.g., leading "." is
112 // not accepted).
113 // * An HTTP GET on the URL must yield a [google.protobuf.Type][]
114 // value in binary format, or produce an error.
115 // * Applications are allowed to cache lookup results based on the
116 // URL, or have them precompiled into a binary to avoid any
117 // lookup. Therefore, binary compatibility needs to be preserved
118 // on changes to types. (Use versioned type names to manage
119 // breaking changes.)
120 //
121 // Schemes other than `http`, `https` (or the empty scheme) might be
122 // used with implementation specific semantics.
123 //
124 TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"`
125 // Must be a valid serialized protocol buffer of the above specified type.
126 Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
127 XXX_NoUnkeyedLiteral struct{} `json:"-"`
128 XXX_unrecognized []byte `json:"-"`
129 XXX_sizecache int32 `json:"-"`
130}
131
132func (m *Any) Reset() { *m = Any{} }
133func (m *Any) String() string { return proto.CompactTextString(m) }
134func (*Any) ProtoMessage() {}
135func (*Any) Descriptor() ([]byte, []int) {
136 return fileDescriptor_any_744b9ca530f228db, []int{0}
137}
138func (*Any) XXX_WellKnownType() string { return "Any" }
139func (m *Any) XXX_Unmarshal(b []byte) error {
140 return xxx_messageInfo_Any.Unmarshal(m, b)
141}
142func (m *Any) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
143 return xxx_messageInfo_Any.Marshal(b, m, deterministic)
144}
145func (dst *Any) XXX_Merge(src proto.Message) {
146 xxx_messageInfo_Any.Merge(dst, src)
147}
148func (m *Any) XXX_Size() int {
149 return xxx_messageInfo_Any.Size(m)
150}
151func (m *Any) XXX_DiscardUnknown() {
152 xxx_messageInfo_Any.DiscardUnknown(m)
153}
154
155var xxx_messageInfo_Any proto.InternalMessageInfo
156
157func (m *Any) GetTypeUrl() string {
158 if m != nil {
159 return m.TypeUrl
160 }
161 return ""
162}
163
164func (m *Any) GetValue() []byte {
165 if m != nil {
166 return m.Value
167 }
168 return nil
169}
170
171func init() {
172 proto.RegisterType((*Any)(nil), "google.protobuf.Any")
173}
174
175func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor_any_744b9ca530f228db) }
176
177var fileDescriptor_any_744b9ca530f228db = []byte{
178 // 185 bytes of a gzipped FileDescriptorProto
179 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcf, 0xcf, 0x4f,
180 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcc, 0xab, 0xd4,
181 0x03, 0x73, 0x84, 0xf8, 0x21, 0x52, 0x7a, 0x30, 0x29, 0x25, 0x33, 0x2e, 0x66, 0xc7, 0xbc, 0x4a,
182 0x21, 0x49, 0x2e, 0x8e, 0x92, 0xca, 0x82, 0xd4, 0xf8, 0xd2, 0xa2, 0x1c, 0x09, 0x46, 0x05, 0x46,
183 0x0d, 0xce, 0x20, 0x76, 0x10, 0x3f, 0xb4, 0x28, 0x47, 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7,
184 0x34, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc2, 0x71, 0xca, 0xe7, 0x12, 0x4e, 0xce,
185 0xcf, 0xd5, 0x43, 0x33, 0xce, 0x89, 0xc3, 0x31, 0xaf, 0x32, 0x00, 0xc4, 0x09, 0x60, 0x8c, 0x52,
186 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc,
187 0x4b, 0x47, 0xb8, 0xa8, 0x00, 0x64, 0x7a, 0x31, 0xc8, 0x61, 0x8b, 0x98, 0x98, 0xdd, 0x03, 0x9c,
188 0x56, 0x31, 0xc9, 0xb9, 0x43, 0x8c, 0x0a, 0x80, 0x2a, 0xd1, 0x0b, 0x4f, 0xcd, 0xc9, 0xf1, 0xce,
189 0xcb, 0x2f, 0xcf, 0x0b, 0x01, 0x29, 0x4d, 0x62, 0x03, 0xeb, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff,
190 0xff, 0x13, 0xf8, 0xe8, 0x42, 0xdd, 0x00, 0x00, 0x00,
191}
diff --git a/vendor/github.com/golang/protobuf/ptypes/any/any.proto b/vendor/github.com/golang/protobuf/ptypes/any/any.proto
new file mode 100644
index 0000000..c748667
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/any/any.proto
@@ -0,0 +1,149 @@
1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15// * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31syntax = "proto3";
32
33package google.protobuf;
34
35option csharp_namespace = "Google.Protobuf.WellKnownTypes";
36option go_package = "github.com/golang/protobuf/ptypes/any";
37option java_package = "com.google.protobuf";
38option java_outer_classname = "AnyProto";
39option java_multiple_files = true;
40option objc_class_prefix = "GPB";
41
42// `Any` contains an arbitrary serialized protocol buffer message along with a
43// URL that describes the type of the serialized message.
44//
45// Protobuf library provides support to pack/unpack Any values in the form
46// of utility functions or additional generated methods of the Any type.
47//
48// Example 1: Pack and unpack a message in C++.
49//
50// Foo foo = ...;
51// Any any;
52// any.PackFrom(foo);
53// ...
54// if (any.UnpackTo(&foo)) {
55// ...
56// }
57//
58// Example 2: Pack and unpack a message in Java.
59//
60// Foo foo = ...;
61// Any any = Any.pack(foo);
62// ...
63// if (any.is(Foo.class)) {
64// foo = any.unpack(Foo.class);
65// }
66//
67// Example 3: Pack and unpack a message in Python.
68//
69// foo = Foo(...)
70// any = Any()
71// any.Pack(foo)
72// ...
73// if any.Is(Foo.DESCRIPTOR):
74// any.Unpack(foo)
75// ...
76//
77// Example 4: Pack and unpack a message in Go
78//
79// foo := &pb.Foo{...}
80// any, err := ptypes.MarshalAny(foo)
81// ...
82// foo := &pb.Foo{}
83// if err := ptypes.UnmarshalAny(any, foo); err != nil {
84// ...
85// }
86//
87// The pack methods provided by protobuf library will by default use
88// 'type.googleapis.com/full.type.name' as the type URL and the unpack
89// methods only use the fully qualified type name after the last '/'
90// in the type URL, for example "foo.bar.com/x/y.z" will yield type
91// name "y.z".
92//
93//
94// JSON
95// ====
96// The JSON representation of an `Any` value uses the regular
97// representation of the deserialized, embedded message, with an
98// additional field `@type` which contains the type URL. Example:
99//
100// package google.profile;
101// message Person {
102// string first_name = 1;
103// string last_name = 2;
104// }
105//
106// {
107// "@type": "type.googleapis.com/google.profile.Person",
108// "firstName": <string>,
109// "lastName": <string>
110// }
111//
112// If the embedded message type is well-known and has a custom JSON
113// representation, that representation will be embedded adding a field
114// `value` which holds the custom JSON in addition to the `@type`
115// field. Example (for message [google.protobuf.Duration][]):
116//
117// {
118// "@type": "type.googleapis.com/google.protobuf.Duration",
119// "value": "1.212s"
120// }
121//
122message Any {
123 // A URL/resource name whose content describes the type of the
124 // serialized protocol buffer message.
125 //
126 // For URLs which use the scheme `http`, `https`, or no scheme, the
127 // following restrictions and interpretations apply:
128 //
129 // * If no scheme is provided, `https` is assumed.
130 // * The last segment of the URL's path must represent the fully
131 // qualified name of the type (as in `path/google.protobuf.Duration`).
132 // The name should be in a canonical form (e.g., leading "." is
133 // not accepted).
134 // * An HTTP GET on the URL must yield a [google.protobuf.Type][]
135 // value in binary format, or produce an error.
136 // * Applications are allowed to cache lookup results based on the
137 // URL, or have them precompiled into a binary to avoid any
138 // lookup. Therefore, binary compatibility needs to be preserved
139 // on changes to types. (Use versioned type names to manage
140 // breaking changes.)
141 //
142 // Schemes other than `http`, `https` (or the empty scheme) might be
143 // used with implementation specific semantics.
144 //
145 string type_url = 1;
146
147 // Must be a valid serialized protocol buffer of the above specified type.
148 bytes value = 2;
149}
diff --git a/vendor/github.com/golang/protobuf/ptypes/doc.go b/vendor/github.com/golang/protobuf/ptypes/doc.go
new file mode 100644
index 0000000..c0d595d
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/doc.go
@@ -0,0 +1,35 @@
1// Go support for Protocol Buffers - Google's data interchange format
2//
3// Copyright 2016 The Go Authors. All rights reserved.
4// https://github.com/golang/protobuf
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16// * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32/*
33Package ptypes contains code for interacting with well-known types.
34*/
35package ptypes
diff --git a/vendor/github.com/golang/protobuf/ptypes/duration.go b/vendor/github.com/golang/protobuf/ptypes/duration.go
new file mode 100644
index 0000000..65cb0f8
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/duration.go
@@ -0,0 +1,102 @@
1// Go support for Protocol Buffers - Google's data interchange format
2//
3// Copyright 2016 The Go Authors. All rights reserved.
4// https://github.com/golang/protobuf
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16// * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32package ptypes
33
34// This file implements conversions between google.protobuf.Duration
35// and time.Duration.
36
37import (
38 "errors"
39 "fmt"
40 "time"
41
42 durpb "github.com/golang/protobuf/ptypes/duration"
43)
44
45const (
46 // Range of a durpb.Duration in seconds, as specified in
47 // google/protobuf/duration.proto. This is about 10,000 years in seconds.
48 maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60)
49 minSeconds = -maxSeconds
50)
51
52// validateDuration determines whether the durpb.Duration is valid according to the
53// definition in google/protobuf/duration.proto. A valid durpb.Duration
54// may still be too large to fit into a time.Duration (the range of durpb.Duration
55// is about 10,000 years, and the range of time.Duration is about 290).
56func validateDuration(d *durpb.Duration) error {
57 if d == nil {
58 return errors.New("duration: nil Duration")
59 }
60 if d.Seconds < minSeconds || d.Seconds > maxSeconds {
61 return fmt.Errorf("duration: %v: seconds out of range", d)
62 }
63 if d.Nanos <= -1e9 || d.Nanos >= 1e9 {
64 return fmt.Errorf("duration: %v: nanos out of range", d)
65 }
66 // Seconds and Nanos must have the same sign, unless d.Nanos is zero.
67 if (d.Seconds < 0 && d.Nanos > 0) || (d.Seconds > 0 && d.Nanos < 0) {
68 return fmt.Errorf("duration: %v: seconds and nanos have different signs", d)
69 }
70 return nil
71}
72
73// Duration converts a durpb.Duration to a time.Duration. Duration
74// returns an error if the durpb.Duration is invalid or is too large to be
75// represented in a time.Duration.
76func Duration(p *durpb.Duration) (time.Duration, error) {
77 if err := validateDuration(p); err != nil {
78 return 0, err
79 }
80 d := time.Duration(p.Seconds) * time.Second
81 if int64(d/time.Second) != p.Seconds {
82 return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
83 }
84 if p.Nanos != 0 {
85 d += time.Duration(p.Nanos)
86 if (d < 0) != (p.Nanos < 0) {
87 return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
88 }
89 }
90 return d, nil
91}
92
93// DurationProto converts a time.Duration to a durpb.Duration.
94func DurationProto(d time.Duration) *durpb.Duration {
95 nanos := d.Nanoseconds()
96 secs := nanos / 1e9
97 nanos -= secs * 1e9
98 return &durpb.Duration{
99 Seconds: secs,
100 Nanos: int32(nanos),
101 }
102}
diff --git a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go
new file mode 100644
index 0000000..a7beb2c
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go
@@ -0,0 +1,159 @@
1// Code generated by protoc-gen-go. DO NOT EDIT.
2// source: google/protobuf/duration.proto
3
4package duration // import "github.com/golang/protobuf/ptypes/duration"
5
6import proto "github.com/golang/protobuf/proto"
7import fmt "fmt"
8import math "math"
9
10// Reference imports to suppress errors if they are not otherwise used.
11var _ = proto.Marshal
12var _ = fmt.Errorf
13var _ = math.Inf
14
15// This is a compile-time assertion to ensure that this generated file
16// is compatible with the proto package it is being compiled against.
17// A compilation error at this line likely means your copy of the
18// proto package needs to be updated.
19const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
20
21// A Duration represents a signed, fixed-length span of time represented
22// as a count of seconds and fractions of seconds at nanosecond
23// resolution. It is independent of any calendar and concepts like "day"
24// or "month". It is related to Timestamp in that the difference between
25// two Timestamp values is a Duration and it can be added or subtracted
26// from a Timestamp. Range is approximately +-10,000 years.
27//
28// # Examples
29//
30// Example 1: Compute Duration from two Timestamps in pseudo code.
31//
32// Timestamp start = ...;
33// Timestamp end = ...;
34// Duration duration = ...;
35//
36// duration.seconds = end.seconds - start.seconds;
37// duration.nanos = end.nanos - start.nanos;
38//
39// if (duration.seconds < 0 && duration.nanos > 0) {
40// duration.seconds += 1;
41// duration.nanos -= 1000000000;
42// } else if (durations.seconds > 0 && duration.nanos < 0) {
43// duration.seconds -= 1;
44// duration.nanos += 1000000000;
45// }
46//
47// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
48//
49// Timestamp start = ...;
50// Duration duration = ...;
51// Timestamp end = ...;
52//
53// end.seconds = start.seconds + duration.seconds;
54// end.nanos = start.nanos + duration.nanos;
55//
56// if (end.nanos < 0) {
57// end.seconds -= 1;
58// end.nanos += 1000000000;
59// } else if (end.nanos >= 1000000000) {
60// end.seconds += 1;
61// end.nanos -= 1000000000;
62// }
63//
64// Example 3: Compute Duration from datetime.timedelta in Python.
65//
66// td = datetime.timedelta(days=3, minutes=10)
67// duration = Duration()
68// duration.FromTimedelta(td)
69//
70// # JSON Mapping
71//
72// In JSON format, the Duration type is encoded as a string rather than an
73// object, where the string ends in the suffix "s" (indicating seconds) and
74// is preceded by the number of seconds, with nanoseconds expressed as
75// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
76// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
77// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
78// microsecond should be expressed in JSON format as "3.000001s".
79//
80//
81type Duration struct {
82 // Signed seconds of the span of time. Must be from -315,576,000,000
83 // to +315,576,000,000 inclusive. Note: these bounds are computed from:
84 // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
85 Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
86 // Signed fractions of a second at nanosecond resolution of the span
87 // of time. Durations less than one second are represented with a 0
88 // `seconds` field and a positive or negative `nanos` field. For durations
89 // of one second or more, a non-zero value for the `nanos` field must be
90 // of the same sign as the `seconds` field. Must be from -999,999,999
91 // to +999,999,999 inclusive.
92 Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
93 XXX_NoUnkeyedLiteral struct{} `json:"-"`
94 XXX_unrecognized []byte `json:"-"`
95 XXX_sizecache int32 `json:"-"`
96}
97
98func (m *Duration) Reset() { *m = Duration{} }
99func (m *Duration) String() string { return proto.CompactTextString(m) }
100func (*Duration) ProtoMessage() {}
101func (*Duration) Descriptor() ([]byte, []int) {
102 return fileDescriptor_duration_e7d612259e3f0613, []int{0}
103}
104func (*Duration) XXX_WellKnownType() string { return "Duration" }
105func (m *Duration) XXX_Unmarshal(b []byte) error {
106 return xxx_messageInfo_Duration.Unmarshal(m, b)
107}
108func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
109 return xxx_messageInfo_Duration.Marshal(b, m, deterministic)
110}
111func (dst *Duration) XXX_Merge(src proto.Message) {
112 xxx_messageInfo_Duration.Merge(dst, src)
113}
114func (m *Duration) XXX_Size() int {
115 return xxx_messageInfo_Duration.Size(m)
116}
117func (m *Duration) XXX_DiscardUnknown() {
118 xxx_messageInfo_Duration.DiscardUnknown(m)
119}
120
121var xxx_messageInfo_Duration proto.InternalMessageInfo
122
123func (m *Duration) GetSeconds() int64 {
124 if m != nil {
125 return m.Seconds
126 }
127 return 0
128}
129
130func (m *Duration) GetNanos() int32 {
131 if m != nil {
132 return m.Nanos
133 }
134 return 0
135}
136
137func init() {
138 proto.RegisterType((*Duration)(nil), "google.protobuf.Duration")
139}
140
141func init() {
142 proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_duration_e7d612259e3f0613)
143}
144
145var fileDescriptor_duration_e7d612259e3f0613 = []byte{
146 // 190 bytes of a gzipped FileDescriptorProto
147 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f,
148 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a,
149 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0x56,
150 0x5c, 0x1c, 0x2e, 0x50, 0x25, 0x42, 0x12, 0x5c, 0xec, 0xc5, 0xa9, 0xc9, 0xf9, 0x79, 0x29, 0xc5,
151 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x30, 0xae, 0x90, 0x08, 0x17, 0x6b, 0x5e, 0x62, 0x5e,
152 0x7e, 0xb1, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x6b, 0x10, 0x84, 0xe3, 0x54, 0xc3, 0x25, 0x9c, 0x9c,
153 0x9f, 0xab, 0x87, 0x66, 0xa4, 0x13, 0x2f, 0xcc, 0xc0, 0x00, 0x90, 0x48, 0x00, 0x63, 0x94, 0x56,
154 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x7a, 0x7e, 0x4e, 0x62, 0x5e,
155 0x3a, 0xc2, 0x7d, 0x05, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x70, 0x67, 0xfe, 0x60, 0x64, 0x5c, 0xc4,
156 0xc4, 0xec, 0x1e, 0xe0, 0xb4, 0x8a, 0x49, 0xce, 0x1d, 0x62, 0x6e, 0x00, 0x54, 0xa9, 0x5e, 0x78,
157 0x6a, 0x4e, 0x8e, 0x77, 0x5e, 0x7e, 0x79, 0x5e, 0x08, 0x48, 0x4b, 0x12, 0x1b, 0xd8, 0x0c, 0x63,
158 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x84, 0x30, 0xff, 0xf3, 0x00, 0x00, 0x00,
159}
diff --git a/vendor/github.com/golang/protobuf/ptypes/duration/duration.proto b/vendor/github.com/golang/protobuf/ptypes/duration/duration.proto
new file mode 100644
index 0000000..975fce4
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/duration/duration.proto
@@ -0,0 +1,117 @@
1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15// * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31syntax = "proto3";
32
33package google.protobuf;
34
35option csharp_namespace = "Google.Protobuf.WellKnownTypes";
36option cc_enable_arenas = true;
37option go_package = "github.com/golang/protobuf/ptypes/duration";
38option java_package = "com.google.protobuf";
39option java_outer_classname = "DurationProto";
40option java_multiple_files = true;
41option objc_class_prefix = "GPB";
42
43// A Duration represents a signed, fixed-length span of time represented
44// as a count of seconds and fractions of seconds at nanosecond
45// resolution. It is independent of any calendar and concepts like "day"
46// or "month". It is related to Timestamp in that the difference between
47// two Timestamp values is a Duration and it can be added or subtracted
48// from a Timestamp. Range is approximately +-10,000 years.
49//
50// # Examples
51//
52// Example 1: Compute Duration from two Timestamps in pseudo code.
53//
54// Timestamp start = ...;
55// Timestamp end = ...;
56// Duration duration = ...;
57//
58// duration.seconds = end.seconds - start.seconds;
59// duration.nanos = end.nanos - start.nanos;
60//
61// if (duration.seconds < 0 && duration.nanos > 0) {
62// duration.seconds += 1;
63// duration.nanos -= 1000000000;
64// } else if (durations.seconds > 0 && duration.nanos < 0) {
65// duration.seconds -= 1;
66// duration.nanos += 1000000000;
67// }
68//
69// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
70//
71// Timestamp start = ...;
72// Duration duration = ...;
73// Timestamp end = ...;
74//
75// end.seconds = start.seconds + duration.seconds;
76// end.nanos = start.nanos + duration.nanos;
77//
78// if (end.nanos < 0) {
79// end.seconds -= 1;
80// end.nanos += 1000000000;
81// } else if (end.nanos >= 1000000000) {
82// end.seconds += 1;
83// end.nanos -= 1000000000;
84// }
85//
86// Example 3: Compute Duration from datetime.timedelta in Python.
87//
88// td = datetime.timedelta(days=3, minutes=10)
89// duration = Duration()
90// duration.FromTimedelta(td)
91//
92// # JSON Mapping
93//
94// In JSON format, the Duration type is encoded as a string rather than an
95// object, where the string ends in the suffix "s" (indicating seconds) and
96// is preceded by the number of seconds, with nanoseconds expressed as
97// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
98// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
99// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
100// microsecond should be expressed in JSON format as "3.000001s".
101//
102//
103message Duration {
104
105 // Signed seconds of the span of time. Must be from -315,576,000,000
106 // to +315,576,000,000 inclusive. Note: these bounds are computed from:
107 // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
108 int64 seconds = 1;
109
110 // Signed fractions of a second at nanosecond resolution of the span
111 // of time. Durations less than one second are represented with a 0
112 // `seconds` field and a positive or negative `nanos` field. For durations
113 // of one second or more, a non-zero value for the `nanos` field must be
114 // of the same sign as the `seconds` field. Must be from -999,999,999
115 // to +999,999,999 inclusive.
116 int32 nanos = 2;
117}
diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp.go b/vendor/github.com/golang/protobuf/ptypes/timestamp.go
new file mode 100644
index 0000000..47f10db
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/timestamp.go
@@ -0,0 +1,134 @@
1// Go support for Protocol Buffers - Google's data interchange format
2//
3// Copyright 2016 The Go Authors. All rights reserved.
4// https://github.com/golang/protobuf
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16// * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32package ptypes
33
34// This file implements operations on google.protobuf.Timestamp.
35
36import (
37 "errors"
38 "fmt"
39 "time"
40
41 tspb "github.com/golang/protobuf/ptypes/timestamp"
42)
43
44const (
45 // Seconds field of the earliest valid Timestamp.
46 // This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix().
47 minValidSeconds = -62135596800
48 // Seconds field just after the latest valid Timestamp.
49 // This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix().
50 maxValidSeconds = 253402300800
51)
52
53// validateTimestamp determines whether a Timestamp is valid.
54// A valid timestamp represents a time in the range
55// [0001-01-01, 10000-01-01) and has a Nanos field
56// in the range [0, 1e9).
57//
58// If the Timestamp is valid, validateTimestamp returns nil.
59// Otherwise, it returns an error that describes
60// the problem.
61//
62// Every valid Timestamp can be represented by a time.Time, but the converse is not true.
63func validateTimestamp(ts *tspb.Timestamp) error {
64 if ts == nil {
65 return errors.New("timestamp: nil Timestamp")
66 }
67 if ts.Seconds < minValidSeconds {
68 return fmt.Errorf("timestamp: %v before 0001-01-01", ts)
69 }
70 if ts.Seconds >= maxValidSeconds {
71 return fmt.Errorf("timestamp: %v after 10000-01-01", ts)
72 }
73 if ts.Nanos < 0 || ts.Nanos >= 1e9 {
74 return fmt.Errorf("timestamp: %v: nanos not in range [0, 1e9)", ts)
75 }
76 return nil
77}
78
79// Timestamp converts a google.protobuf.Timestamp proto to a time.Time.
80// It returns an error if the argument is invalid.
81//
82// Unlike most Go functions, if Timestamp returns an error, the first return value
83// is not the zero time.Time. Instead, it is the value obtained from the
84// time.Unix function when passed the contents of the Timestamp, in the UTC
85// locale. This may or may not be a meaningful time; many invalid Timestamps
86// do map to valid time.Times.
87//
88// A nil Timestamp returns an error. The first return value in that case is
89// undefined.
90func Timestamp(ts *tspb.Timestamp) (time.Time, error) {
91 // Don't return the zero value on error, because corresponds to a valid
92 // timestamp. Instead return whatever time.Unix gives us.
93 var t time.Time
94 if ts == nil {
95 t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp
96 } else {
97 t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC()
98 }
99 return t, validateTimestamp(ts)
100}
101
102// TimestampNow returns a google.protobuf.Timestamp for the current time.
103func TimestampNow() *tspb.Timestamp {
104 ts, err := TimestampProto(time.Now())
105 if err != nil {
106 panic("ptypes: time.Now() out of Timestamp range")
107 }
108 return ts
109}
110
111// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
112// It returns an error if the resulting Timestamp is invalid.
113func TimestampProto(t time.Time) (*tspb.Timestamp, error) {
114 seconds := t.Unix()
115 nanos := int32(t.Sub(time.Unix(seconds, 0)))
116 ts := &tspb.Timestamp{
117 Seconds: seconds,
118 Nanos: nanos,
119 }
120 if err := validateTimestamp(ts); err != nil {
121 return nil, err
122 }
123 return ts, nil
124}
125
126// TimestampString returns the RFC 3339 string for valid Timestamps. For invalid
127// Timestamps, it returns an error message in parentheses.
128func TimestampString(ts *tspb.Timestamp) string {
129 t, err := Timestamp(ts)
130 if err != nil {
131 return fmt.Sprintf("(%v)", err)
132 }
133 return t.Format(time.RFC3339Nano)
134}
diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go
new file mode 100644
index 0000000..8e76ae9
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go
@@ -0,0 +1,175 @@
1// Code generated by protoc-gen-go. DO NOT EDIT.
2// source: google/protobuf/timestamp.proto
3
4package timestamp // import "github.com/golang/protobuf/ptypes/timestamp"
5
6import proto "github.com/golang/protobuf/proto"
7import fmt "fmt"
8import math "math"
9
10// Reference imports to suppress errors if they are not otherwise used.
11var _ = proto.Marshal
12var _ = fmt.Errorf
13var _ = math.Inf
14
15// This is a compile-time assertion to ensure that this generated file
16// is compatible with the proto package it is being compiled against.
17// A compilation error at this line likely means your copy of the
18// proto package needs to be updated.
19const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
20
21// A Timestamp represents a point in time independent of any time zone
22// or calendar, represented as seconds and fractions of seconds at
23// nanosecond resolution in UTC Epoch time. It is encoded using the
24// Proleptic Gregorian Calendar which extends the Gregorian calendar
25// backwards to year one. It is encoded assuming all minutes are 60
26// seconds long, i.e. leap seconds are "smeared" so that no leap second
27// table is needed for interpretation. Range is from
28// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
29// By restricting to that range, we ensure that we can convert to
30// and from RFC 3339 date strings.
31// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
32//
33// # Examples
34//
35// Example 1: Compute Timestamp from POSIX `time()`.
36//
37// Timestamp timestamp;
38// timestamp.set_seconds(time(NULL));
39// timestamp.set_nanos(0);
40//
41// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
42//
43// struct timeval tv;
44// gettimeofday(&tv, NULL);
45//
46// Timestamp timestamp;
47// timestamp.set_seconds(tv.tv_sec);
48// timestamp.set_nanos(tv.tv_usec * 1000);
49//
50// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
51//
52// FILETIME ft;
53// GetSystemTimeAsFileTime(&ft);
54// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
55//
56// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
57// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
58// Timestamp timestamp;
59// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
60// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
61//
62// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
63//
64// long millis = System.currentTimeMillis();
65//
66// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
67// .setNanos((int) ((millis % 1000) * 1000000)).build();
68//
69//
70// Example 5: Compute Timestamp from current time in Python.
71//
72// timestamp = Timestamp()
73// timestamp.GetCurrentTime()
74//
75// # JSON Mapping
76//
77// In JSON format, the Timestamp type is encoded as a string in the
78// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
79// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
80// where {year} is always expressed using four digits while {month}, {day},
81// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
82// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
83// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
84// is required, though only UTC (as indicated by "Z") is presently supported.
85//
86// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
87// 01:30 UTC on January 15, 2017.
88//
89// In JavaScript, one can convert a Date object to this format using the
90// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
91// method. In Python, a standard `datetime.datetime` object can be converted
92// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
93// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
94// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
95// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--)
96// to obtain a formatter capable of generating timestamps in this format.
97//
98//
99type Timestamp struct {
100 // Represents seconds of UTC time since Unix epoch
101 // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
102 // 9999-12-31T23:59:59Z inclusive.
103 Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
104 // Non-negative fractions of a second at nanosecond resolution. Negative
105 // second values with fractions must still have non-negative nanos values
106 // that count forward in time. Must be from 0 to 999,999,999
107 // inclusive.
108 Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
109 XXX_NoUnkeyedLiteral struct{} `json:"-"`
110 XXX_unrecognized []byte `json:"-"`
111 XXX_sizecache int32 `json:"-"`
112}
113
114func (m *Timestamp) Reset() { *m = Timestamp{} }
115func (m *Timestamp) String() string { return proto.CompactTextString(m) }
116func (*Timestamp) ProtoMessage() {}
117func (*Timestamp) Descriptor() ([]byte, []int) {
118 return fileDescriptor_timestamp_b826e8e5fba671a8, []int{0}
119}
120func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" }
121func (m *Timestamp) XXX_Unmarshal(b []byte) error {
122 return xxx_messageInfo_Timestamp.Unmarshal(m, b)
123}
124func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
125 return xxx_messageInfo_Timestamp.Marshal(b, m, deterministic)
126}
127func (dst *Timestamp) XXX_Merge(src proto.Message) {
128 xxx_messageInfo_Timestamp.Merge(dst, src)
129}
130func (m *Timestamp) XXX_Size() int {
131 return xxx_messageInfo_Timestamp.Size(m)
132}
133func (m *Timestamp) XXX_DiscardUnknown() {
134 xxx_messageInfo_Timestamp.DiscardUnknown(m)
135}
136
137var xxx_messageInfo_Timestamp proto.InternalMessageInfo
138
139func (m *Timestamp) GetSeconds() int64 {
140 if m != nil {
141 return m.Seconds
142 }
143 return 0
144}
145
146func (m *Timestamp) GetNanos() int32 {
147 if m != nil {
148 return m.Nanos
149 }
150 return 0
151}
152
153func init() {
154 proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp")
155}
156
157func init() {
158 proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor_timestamp_b826e8e5fba671a8)
159}
160
161var fileDescriptor_timestamp_b826e8e5fba671a8 = []byte{
162 // 191 bytes of a gzipped FileDescriptorProto
163 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcf, 0xcf, 0x4f,
164 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xc9, 0xcc, 0x4d,
165 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0xd0, 0x03, 0x0b, 0x09, 0xf1, 0x43, 0x14, 0xe8, 0xc1, 0x14, 0x28,
166 0x59, 0x73, 0x71, 0x86, 0xc0, 0xd4, 0x08, 0x49, 0x70, 0xb1, 0x17, 0xa7, 0x26, 0xe7, 0xe7, 0xa5,
167 0x14, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0xc1, 0xb8, 0x42, 0x22, 0x5c, 0xac, 0x79, 0x89,
168 0x79, 0xf9, 0xc5, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0x10, 0x8e, 0x53, 0x1d, 0x97, 0x70,
169 0x72, 0x7e, 0xae, 0x1e, 0x9a, 0x99, 0x4e, 0x7c, 0x70, 0x13, 0x03, 0x40, 0x42, 0x01, 0x8c, 0x51,
170 0xda, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe9, 0xf9, 0x39, 0x89,
171 0x79, 0xe9, 0x08, 0x27, 0x16, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x23, 0x5c, 0xfa, 0x83, 0x91, 0x71,
172 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0xc9, 0x01, 0x50, 0xb5, 0x7a,
173 0xe1, 0xa9, 0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x3d, 0x49, 0x6c, 0x60, 0x43,
174 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x77, 0x4a, 0x07, 0xf7, 0x00, 0x00, 0x00,
175}
diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
new file mode 100644
index 0000000..06750ab
--- /dev/null
+++ b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
@@ -0,0 +1,133 @@
1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15// * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31syntax = "proto3";
32
33package google.protobuf;
34
35option csharp_namespace = "Google.Protobuf.WellKnownTypes";
36option cc_enable_arenas = true;
37option go_package = "github.com/golang/protobuf/ptypes/timestamp";
38option java_package = "com.google.protobuf";
39option java_outer_classname = "TimestampProto";
40option java_multiple_files = true;
41option objc_class_prefix = "GPB";
42
43// A Timestamp represents a point in time independent of any time zone
44// or calendar, represented as seconds and fractions of seconds at
45// nanosecond resolution in UTC Epoch time. It is encoded using the
46// Proleptic Gregorian Calendar which extends the Gregorian calendar
47// backwards to year one. It is encoded assuming all minutes are 60
48// seconds long, i.e. leap seconds are "smeared" so that no leap second
49// table is needed for interpretation. Range is from
50// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
51// By restricting to that range, we ensure that we can convert to
52// and from RFC 3339 date strings.
53// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
54//
55// # Examples
56//
57// Example 1: Compute Timestamp from POSIX `time()`.
58//
59// Timestamp timestamp;
60// timestamp.set_seconds(time(NULL));
61// timestamp.set_nanos(0);
62//
63// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
64//
65// struct timeval tv;
66// gettimeofday(&tv, NULL);
67//
68// Timestamp timestamp;
69// timestamp.set_seconds(tv.tv_sec);
70// timestamp.set_nanos(tv.tv_usec * 1000);
71//
72// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
73//
74// FILETIME ft;
75// GetSystemTimeAsFileTime(&ft);
76// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
77//
78// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
79// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
80// Timestamp timestamp;
81// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
82// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
83//
84// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
85//
86// long millis = System.currentTimeMillis();
87//
88// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
89// .setNanos((int) ((millis % 1000) * 1000000)).build();
90//
91//
92// Example 5: Compute Timestamp from current time in Python.
93//
94// timestamp = Timestamp()
95// timestamp.GetCurrentTime()
96//
97// # JSON Mapping
98//
99// In JSON format, the Timestamp type is encoded as a string in the
100// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
101// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
102// where {year} is always expressed using four digits while {month}, {day},
103// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
104// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
105// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
106// is required, though only UTC (as indicated by "Z") is presently supported.
107//
108// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
109// 01:30 UTC on January 15, 2017.
110//
111// In JavaScript, one can convert a Date object to this format using the
112// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
113// method. In Python, a standard `datetime.datetime` object can be converted
114// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
115// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
116// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
117// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--)
118// to obtain a formatter capable of generating timestamps in this format.
119//
120//
121message Timestamp {
122
123 // Represents seconds of UTC time since Unix epoch
124 // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
125 // 9999-12-31T23:59:59Z inclusive.
126 int64 seconds = 1;
127
128 // Non-negative fractions of a second at nanosecond resolution. Negative
129 // second values with fractions must still have non-negative nanos values
130 // that count forward in time. Must be from 0 to 999,999,999
131 // inclusive.
132 int32 nanos = 2;
133}