google-cloud-vision-v1p3beta1 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +203 -0
- data/README.md +24 -0
- data/lib/google-cloud-vision-v1p3beta1.rb +1 -0
- data/lib/google/cloud/common_resources_pb.rb +15 -0
- data/lib/google/cloud/vision/v1p3beta1.rb +20 -0
- data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +44 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator.rb +21 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/client.rb +462 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/credentials.rb +52 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/helpers.rb +1228 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/operations.rb +558 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/paths.rb +52 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +307 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +55 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search.rb +21 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search/client.rb +2033 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search/credentials.rb +52 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search/operations.rb +558 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search/paths.rb +109 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +66 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +195 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +222 -0
- data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +95 -0
- data/lib/google/cloud/vision/v1p3beta1/version.rb +28 -0
- data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +52 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/field_behavior.rb +59 -0
- data/proto_docs/google/api/resource.rb +247 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/geometry.rb +91 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/image_annotator.rb +869 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/product_search.rb +172 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/product_search_service.rb +630 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/text_annotation.rb +286 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/web_detection.rb +120 -0
- data/proto_docs/google/longrunning/operations.rb +150 -0
- data/proto_docs/google/protobuf/any.rb +137 -0
- data/proto_docs/google/protobuf/empty.rb +36 -0
- data/proto_docs/google/protobuf/field_mask.rb +237 -0
- data/proto_docs/google/protobuf/timestamp.rb +116 -0
- data/proto_docs/google/protobuf/wrappers.rb +121 -0
- data/proto_docs/google/rpc/status.rb +46 -0
- data/proto_docs/google/type/color.rb +168 -0
- data/proto_docs/google/type/latlng.rb +38 -0
- metadata +201 -0
@@ -0,0 +1,137 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Protobuf
|
22
|
+
# `Any` contains an arbitrary serialized protocol buffer message along with a
|
23
|
+
# URL that describes the type of the serialized message.
|
24
|
+
#
|
25
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
26
|
+
# of utility functions or additional generated methods of the Any type.
|
27
|
+
#
|
28
|
+
# Example 1: Pack and unpack a message in C++.
|
29
|
+
#
|
30
|
+
# Foo foo = ...;
|
31
|
+
# Any any;
|
32
|
+
# any.PackFrom(foo);
|
33
|
+
# ...
|
34
|
+
# if (any.UnpackTo(&foo)) {
|
35
|
+
# ...
|
36
|
+
# }
|
37
|
+
#
|
38
|
+
# Example 2: Pack and unpack a message in Java.
|
39
|
+
#
|
40
|
+
# Foo foo = ...;
|
41
|
+
# Any any = Any.pack(foo);
|
42
|
+
# ...
|
43
|
+
# if (any.is(Foo.class)) {
|
44
|
+
# foo = any.unpack(Foo.class);
|
45
|
+
# }
|
46
|
+
#
|
47
|
+
# Example 3: Pack and unpack a message in Python.
|
48
|
+
#
|
49
|
+
# foo = Foo(...)
|
50
|
+
# any = Any()
|
51
|
+
# any.Pack(foo)
|
52
|
+
# ...
|
53
|
+
# if any.Is(Foo.DESCRIPTOR):
|
54
|
+
# any.Unpack(foo)
|
55
|
+
# ...
|
56
|
+
#
|
57
|
+
# Example 4: Pack and unpack a message in Go
|
58
|
+
#
|
59
|
+
# foo := &pb.Foo{...}
|
60
|
+
# any, err := ptypes.MarshalAny(foo)
|
61
|
+
# ...
|
62
|
+
# foo := &pb.Foo{}
|
63
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
64
|
+
# ...
|
65
|
+
# }
|
66
|
+
#
|
67
|
+
# The pack methods provided by protobuf library will by default use
|
68
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
69
|
+
# methods only use the fully qualified type name after the last '/'
|
70
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
71
|
+
# name "y.z".
|
72
|
+
#
|
73
|
+
#
|
74
|
+
# JSON
|
75
|
+
# ====
|
76
|
+
# The JSON representation of an `Any` value uses the regular
|
77
|
+
# representation of the deserialized, embedded message, with an
|
78
|
+
# additional field `@type` which contains the type URL. Example:
|
79
|
+
#
|
80
|
+
# package google.profile;
|
81
|
+
# message Person {
|
82
|
+
# string first_name = 1;
|
83
|
+
# string last_name = 2;
|
84
|
+
# }
|
85
|
+
#
|
86
|
+
# {
|
87
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
88
|
+
# "firstName": <string>,
|
89
|
+
# "lastName": <string>
|
90
|
+
# }
|
91
|
+
#
|
92
|
+
# If the embedded message type is well-known and has a custom JSON
|
93
|
+
# representation, that representation will be embedded adding a field
|
94
|
+
# `value` which holds the custom JSON in addition to the `@type`
|
95
|
+
# field. Example (for message [google.protobuf.Duration][]):
|
96
|
+
#
|
97
|
+
# {
|
98
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
99
|
+
# "value": "1.212s"
|
100
|
+
# }
|
101
|
+
# @!attribute [rw] type_url
|
102
|
+
# @return [String]
|
103
|
+
# A URL/resource name that uniquely identifies the type of the serialized
|
104
|
+
# protocol buffer message. The last segment of the URL's path must represent
|
105
|
+
# the fully qualified name of the type (as in
|
106
|
+
# `path/google.protobuf.Duration`). The name should be in a canonical form
|
107
|
+
# (e.g., leading "." is not accepted).
|
108
|
+
#
|
109
|
+
# In practice, teams usually precompile into the binary all types that they
|
110
|
+
# expect it to use in the context of Any. However, for URLs which use the
|
111
|
+
# scheme `http`, `https`, or no scheme, one can optionally set up a type
|
112
|
+
# server that maps type URLs to message definitions as follows:
|
113
|
+
#
|
114
|
+
# * If no scheme is provided, `https` is assumed.
|
115
|
+
# * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
116
|
+
# value in binary format, or produce an error.
|
117
|
+
# * Applications are allowed to cache lookup results based on the
|
118
|
+
# URL, or have them precompiled into a binary to avoid any
|
119
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
120
|
+
# on changes to types. (Use versioned type names to manage
|
121
|
+
# breaking changes.)
|
122
|
+
#
|
123
|
+
# Note: this functionality is not currently available in the official
|
124
|
+
# protobuf release, and it is not used for type URLs beginning with
|
125
|
+
# type.googleapis.com.
|
126
|
+
#
|
127
|
+
# Schemes other than `http`, `https` (or the empty scheme) might be
|
128
|
+
# used with implementation specific semantics.
|
129
|
+
# @!attribute [rw] value
|
130
|
+
# @return [String]
|
131
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
132
|
+
class Any
|
133
|
+
include Google::Protobuf::MessageExts
|
134
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Protobuf
|
22
|
+
# A generic empty message that you can re-use to avoid defining duplicated
|
23
|
+
# empty messages in your APIs. A typical example is to use it as the request
|
24
|
+
# or the response type of an API method. For instance:
|
25
|
+
#
|
26
|
+
# service Foo {
|
27
|
+
# rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
28
|
+
# }
|
29
|
+
#
|
30
|
+
# The JSON representation for `Empty` is empty JSON object `{}`.
|
31
|
+
class Empty
|
32
|
+
include Google::Protobuf::MessageExts
|
33
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Protobuf
|
22
|
+
# `FieldMask` represents a set of symbolic field paths, for example:
|
23
|
+
#
|
24
|
+
# paths: "f.a"
|
25
|
+
# paths: "f.b.d"
|
26
|
+
#
|
27
|
+
# Here `f` represents a field in some root message, `a` and `b`
|
28
|
+
# fields in the message found in `f`, and `d` a field found in the
|
29
|
+
# message in `f.b`.
|
30
|
+
#
|
31
|
+
# Field masks are used to specify a subset of fields that should be
|
32
|
+
# returned by a get operation or modified by an update operation.
|
33
|
+
# Field masks also have a custom JSON encoding (see below).
|
34
|
+
#
|
35
|
+
# # Field Masks in Projections
|
36
|
+
#
|
37
|
+
# When used in the context of a projection, a response message or
|
38
|
+
# sub-message is filtered by the API to only contain those fields as
|
39
|
+
# specified in the mask. For example, if the mask in the previous
|
40
|
+
# example is applied to a response message as follows:
|
41
|
+
#
|
42
|
+
# f {
|
43
|
+
# a : 22
|
44
|
+
# b {
|
45
|
+
# d : 1
|
46
|
+
# x : 2
|
47
|
+
# }
|
48
|
+
# y : 13
|
49
|
+
# }
|
50
|
+
# z: 8
|
51
|
+
#
|
52
|
+
# The result will not contain specific values for fields x,y and z
|
53
|
+
# (their value will be set to the default, and omitted in proto text
|
54
|
+
# output):
|
55
|
+
#
|
56
|
+
#
|
57
|
+
# f {
|
58
|
+
# a : 22
|
59
|
+
# b {
|
60
|
+
# d : 1
|
61
|
+
# }
|
62
|
+
# }
|
63
|
+
#
|
64
|
+
# A repeated field is not allowed except at the last position of a
|
65
|
+
# paths string.
|
66
|
+
#
|
67
|
+
# If a FieldMask object is not present in a get operation, the
|
68
|
+
# operation applies to all fields (as if a FieldMask of all fields
|
69
|
+
# had been specified).
|
70
|
+
#
|
71
|
+
# Note that a field mask does not necessarily apply to the
|
72
|
+
# top-level response message. In case of a REST get operation, the
|
73
|
+
# field mask applies directly to the response, but in case of a REST
|
74
|
+
# list operation, the mask instead applies to each individual message
|
75
|
+
# in the returned resource list. In case of a REST custom method,
|
76
|
+
# other definitions may be used. Where the mask applies will be
|
77
|
+
# clearly documented together with its declaration in the API. In
|
78
|
+
# any case, the effect on the returned resource/resources is required
|
79
|
+
# behavior for APIs.
|
80
|
+
#
|
81
|
+
# # Field Masks in Update Operations
|
82
|
+
#
|
83
|
+
# A field mask in update operations specifies which fields of the
|
84
|
+
# targeted resource are going to be updated. The API is required
|
85
|
+
# to only change the values of the fields as specified in the mask
|
86
|
+
# and leave the others untouched. If a resource is passed in to
|
87
|
+
# describe the updated values, the API ignores the values of all
|
88
|
+
# fields not covered by the mask.
|
89
|
+
#
|
90
|
+
# If a repeated field is specified for an update operation, the existing
|
91
|
+
# repeated values in the target resource will be overwritten by the new values.
|
92
|
+
# Note that a repeated field is only allowed in the last position of a `paths`
|
93
|
+
# string.
|
94
|
+
#
|
95
|
+
# If a sub-message is specified in the last position of the field mask for an
|
96
|
+
# update operation, then the existing sub-message in the target resource is
|
97
|
+
# overwritten. Given the target message:
|
98
|
+
#
|
99
|
+
# f {
|
100
|
+
# b {
|
101
|
+
# d : 1
|
102
|
+
# x : 2
|
103
|
+
# }
|
104
|
+
# c : 1
|
105
|
+
# }
|
106
|
+
#
|
107
|
+
# And an update message:
|
108
|
+
#
|
109
|
+
# f {
|
110
|
+
# b {
|
111
|
+
# d : 10
|
112
|
+
# }
|
113
|
+
# }
|
114
|
+
#
|
115
|
+
# then if the field mask is:
|
116
|
+
#
|
117
|
+
# paths: "f.b"
|
118
|
+
#
|
119
|
+
# then the result will be:
|
120
|
+
#
|
121
|
+
# f {
|
122
|
+
# b {
|
123
|
+
# d : 10
|
124
|
+
# }
|
125
|
+
# c : 1
|
126
|
+
# }
|
127
|
+
#
|
128
|
+
# However, if the update mask was:
|
129
|
+
#
|
130
|
+
# paths: "f.b.d"
|
131
|
+
#
|
132
|
+
# then the result would be:
|
133
|
+
#
|
134
|
+
# f {
|
135
|
+
# b {
|
136
|
+
# d : 10
|
137
|
+
# x : 2
|
138
|
+
# }
|
139
|
+
# c : 1
|
140
|
+
# }
|
141
|
+
#
|
142
|
+
# In order to reset a field's value to the default, the field must
|
143
|
+
# be in the mask and set to the default value in the provided resource.
|
144
|
+
# Hence, in order to reset all fields of a resource, provide a default
|
145
|
+
# instance of the resource and set all fields in the mask, or do
|
146
|
+
# not provide a mask as described below.
|
147
|
+
#
|
148
|
+
# If a field mask is not present on update, the operation applies to
|
149
|
+
# all fields (as if a field mask of all fields has been specified).
|
150
|
+
# Note that in the presence of schema evolution, this may mean that
|
151
|
+
# fields the client does not know and has therefore not filled into
|
152
|
+
# the request will be reset to their default. If this is unwanted
|
153
|
+
# behavior, a specific service may require a client to always specify
|
154
|
+
# a field mask, producing an error if not.
|
155
|
+
#
|
156
|
+
# As with get operations, the location of the resource which
|
157
|
+
# describes the updated values in the request message depends on the
|
158
|
+
# operation kind. In any case, the effect of the field mask is
|
159
|
+
# required to be honored by the API.
|
160
|
+
#
|
161
|
+
# ## Considerations for HTTP REST
|
162
|
+
#
|
163
|
+
# The HTTP kind of an update operation which uses a field mask must
|
164
|
+
# be set to PATCH instead of PUT in order to satisfy HTTP semantics
|
165
|
+
# (PUT must only be used for full updates).
|
166
|
+
#
|
167
|
+
# # JSON Encoding of Field Masks
|
168
|
+
#
|
169
|
+
# In JSON, a field mask is encoded as a single string where paths are
|
170
|
+
# separated by a comma. Fields name in each path are converted
|
171
|
+
# to/from lower-camel naming conventions.
|
172
|
+
#
|
173
|
+
# As an example, consider the following message declarations:
|
174
|
+
#
|
175
|
+
# message Profile {
|
176
|
+
# User user = 1;
|
177
|
+
# Photo photo = 2;
|
178
|
+
# }
|
179
|
+
# message User {
|
180
|
+
# string display_name = 1;
|
181
|
+
# string address = 2;
|
182
|
+
# }
|
183
|
+
#
|
184
|
+
# In proto a field mask for `Profile` may look as such:
|
185
|
+
#
|
186
|
+
# mask {
|
187
|
+
# paths: "user.display_name"
|
188
|
+
# paths: "photo"
|
189
|
+
# }
|
190
|
+
#
|
191
|
+
# In JSON, the same mask is represented as below:
|
192
|
+
#
|
193
|
+
# {
|
194
|
+
# mask: "user.displayName,photo"
|
195
|
+
# }
|
196
|
+
#
|
197
|
+
# # Field Masks and Oneof Fields
|
198
|
+
#
|
199
|
+
# Field masks treat fields in oneofs just as regular fields. Consider the
|
200
|
+
# following message:
|
201
|
+
#
|
202
|
+
# message SampleMessage {
|
203
|
+
# oneof test_oneof {
|
204
|
+
# string name = 4;
|
205
|
+
# SubMessage sub_message = 9;
|
206
|
+
# }
|
207
|
+
# }
|
208
|
+
#
|
209
|
+
# The field mask can be:
|
210
|
+
#
|
211
|
+
# mask {
|
212
|
+
# paths: "name"
|
213
|
+
# }
|
214
|
+
#
|
215
|
+
# Or:
|
216
|
+
#
|
217
|
+
# mask {
|
218
|
+
# paths: "sub_message"
|
219
|
+
# }
|
220
|
+
#
|
221
|
+
# Note that oneof type names ("test_oneof" in this case) cannot be used in
|
222
|
+
# paths.
|
223
|
+
#
|
224
|
+
# ## Field Mask Verification
|
225
|
+
#
|
226
|
+
# The implementation of any API method which has a FieldMask type field in the
|
227
|
+
# request should verify the included field paths, and return an
|
228
|
+
# `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
|
229
|
+
# @!attribute [rw] paths
|
230
|
+
# @return [Array<String>]
|
231
|
+
# The set of field mask paths.
|
232
|
+
class FieldMask
|
233
|
+
include Google::Protobuf::MessageExts
|
234
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Protobuf
|
22
|
+
# A Timestamp represents a point in time independent of any time zone
|
23
|
+
# or calendar, represented as seconds and fractions of seconds at
|
24
|
+
# nanosecond resolution in UTC Epoch time. It is encoded using the
|
25
|
+
# Proleptic Gregorian Calendar which extends the Gregorian calendar
|
26
|
+
# backwards to year one. It is encoded assuming all minutes are 60
|
27
|
+
# seconds long, i.e. leap seconds are "smeared" so that no leap second
|
28
|
+
# table is needed for interpretation. Range is from
|
29
|
+
# 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
|
30
|
+
# By restricting to that range, we ensure that we can convert to
|
31
|
+
# and from RFC 3339 date strings.
|
32
|
+
# See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
|
33
|
+
#
|
34
|
+
# # Examples
|
35
|
+
#
|
36
|
+
# Example 1: Compute Timestamp from POSIX `time()`.
|
37
|
+
#
|
38
|
+
# Timestamp timestamp;
|
39
|
+
# timestamp.set_seconds(time(NULL));
|
40
|
+
# timestamp.set_nanos(0);
|
41
|
+
#
|
42
|
+
# Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
43
|
+
#
|
44
|
+
# struct timeval tv;
|
45
|
+
# gettimeofday(&tv, NULL);
|
46
|
+
#
|
47
|
+
# Timestamp timestamp;
|
48
|
+
# timestamp.set_seconds(tv.tv_sec);
|
49
|
+
# timestamp.set_nanos(tv.tv_usec * 1000);
|
50
|
+
#
|
51
|
+
# Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
52
|
+
#
|
53
|
+
# FILETIME ft;
|
54
|
+
# GetSystemTimeAsFileTime(&ft);
|
55
|
+
# UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
56
|
+
#
|
57
|
+
# // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
58
|
+
# // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
59
|
+
# Timestamp timestamp;
|
60
|
+
# timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
61
|
+
# timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
62
|
+
#
|
63
|
+
# Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
64
|
+
#
|
65
|
+
# long millis = System.currentTimeMillis();
|
66
|
+
#
|
67
|
+
# Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
68
|
+
# .setNanos((int) ((millis % 1000) * 1000000)).build();
|
69
|
+
#
|
70
|
+
#
|
71
|
+
# Example 5: Compute Timestamp from current time in Python.
|
72
|
+
#
|
73
|
+
# timestamp = Timestamp()
|
74
|
+
# timestamp.GetCurrentTime()
|
75
|
+
#
|
76
|
+
# # JSON Mapping
|
77
|
+
#
|
78
|
+
# In JSON format, the Timestamp type is encoded as a string in the
|
79
|
+
# [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
80
|
+
# format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z"
|
81
|
+
# where \\{year} is always expressed using four digits while \\{month}, \\{day},
|
82
|
+
# \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional
|
83
|
+
# seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
84
|
+
# are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
85
|
+
# is required. A proto3 JSON serializer should always use UTC (as indicated by
|
86
|
+
# "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
87
|
+
# able to accept both UTC and other timezones (as indicated by an offset).
|
88
|
+
#
|
89
|
+
# For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
90
|
+
# 01:30 UTC on January 15, 2017.
|
91
|
+
#
|
92
|
+
# In JavaScript, one can convert a Date object to this format using the
|
93
|
+
# standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
|
94
|
+
# method. In Python, a standard `datetime.datetime` object can be converted
|
95
|
+
# to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
|
96
|
+
# with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
|
97
|
+
# can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
98
|
+
# http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
|
99
|
+
# ) to obtain a formatter capable of generating timestamps in this format.
|
100
|
+
# @!attribute [rw] seconds
|
101
|
+
# @return [Integer]
|
102
|
+
# Represents seconds of UTC time since Unix epoch
|
103
|
+
# 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
104
|
+
# 9999-12-31T23:59:59Z inclusive.
|
105
|
+
# @!attribute [rw] nanos
|
106
|
+
# @return [Integer]
|
107
|
+
# Non-negative fractions of a second at nanosecond resolution. Negative
|
108
|
+
# second values with fractions must still have non-negative nanos values
|
109
|
+
# that count forward in time. Must be from 0 to 999,999,999
|
110
|
+
# inclusive.
|
111
|
+
class Timestamp
|
112
|
+
include Google::Protobuf::MessageExts
|
113
|
+
extend Google::Protobuf::MessageExts::ClassMethods
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|