google-cloud-scheduler 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 +9 -0
- data/LICENSE +201 -0
- data/README.md +68 -0
- data/lib/google/cloud/scheduler.rb +141 -0
- data/lib/google/cloud/scheduler/v1beta1.rb +139 -0
- data/lib/google/cloud/scheduler/v1beta1/cloud_scheduler_client.rb +609 -0
- data/lib/google/cloud/scheduler/v1beta1/cloud_scheduler_client_config.json +66 -0
- data/lib/google/cloud/scheduler/v1beta1/cloudscheduler_pb.rb +62 -0
- data/lib/google/cloud/scheduler/v1beta1/cloudscheduler_services_pb.rb +84 -0
- data/lib/google/cloud/scheduler/v1beta1/credentials.rb +41 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/cloudscheduler.rb +142 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/job.rb +199 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/target.rb +280 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/any.rb +130 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/duration.rb +91 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/field_mask.rb +230 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/timestamp.rb +109 -0
- data/lib/google/cloud/scheduler/v1beta1/doc/google/rpc/status.rb +84 -0
- data/lib/google/cloud/scheduler/v1beta1/helpers.rb +48 -0
- data/lib/google/cloud/scheduler/v1beta1/job_pb.rb +56 -0
- data/lib/google/cloud/scheduler/v1beta1/target_pb.rb +58 -0
- metadata +149 -0
@@ -0,0 +1,280 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Cloud
|
18
|
+
module Scheduler
|
19
|
+
module V1beta1
|
20
|
+
# Http target. The job will be pushed to the job handler by means of
|
21
|
+
# an HTTP request via an {Google::Cloud::Scheduler::V1beta1::HttpTarget#http_method http_method} such as HTTP
|
22
|
+
# POST, HTTP GET, etc. The job is acknowledged by means of an HTTP
|
23
|
+
# response code in the range [200 - 299]. A failure to receive a response
|
24
|
+
# constitutes a failed execution. For a redirected request, the response
|
25
|
+
# returned by the redirected request is considered.
|
26
|
+
# @!attribute [rw] uri
|
27
|
+
# @return [String]
|
28
|
+
# Required.
|
29
|
+
#
|
30
|
+
# The full URI path that the request will be sent to. This string
|
31
|
+
# must begin with either "http://" or "https://". Some examples of
|
32
|
+
# valid values for {Google::Cloud::Scheduler::V1beta1::HttpTarget#uri uri} are:
|
33
|
+
# `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will
|
34
|
+
# encode some characters for safety and compatibility. The maximum allowed
|
35
|
+
# URL length is 2083 characters after encoding.
|
36
|
+
# @!attribute [rw] http_method
|
37
|
+
# @return [Google::Cloud::Scheduler::V1beta1::HttpMethod]
|
38
|
+
# Which HTTP method to use for the request.
|
39
|
+
# @!attribute [rw] headers
|
40
|
+
# @return [Hash{String => String}]
|
41
|
+
# The user can specify HTTP request headers to send with the job's
|
42
|
+
# HTTP request. This map contains the header field names and
|
43
|
+
# values. Repeated headers are not supported, but a header value can
|
44
|
+
# contain commas. These headers represent a subset of the headers
|
45
|
+
# that will accompany the job's HTTP request. Some HTTP request
|
46
|
+
# headers will be ignored or replaced. A partial list of headers that
|
47
|
+
# will be ignored or replaced is below:
|
48
|
+
# * Host: This will be computed by Cloud Scheduler and derived from
|
49
|
+
# {Google::Cloud::Scheduler::V1beta1::HttpTarget#uri uri}.
|
50
|
+
# * `Content-Length`: This will be computed by Cloud Scheduler.
|
51
|
+
# * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`.
|
52
|
+
# * `X-Google-*`: Google internal use only.
|
53
|
+
# * `X-AppEngine-*`: Google internal use only.
|
54
|
+
#
|
55
|
+
# The total size of headers must be less than 80KB.
|
56
|
+
# @!attribute [rw] body
|
57
|
+
# @return [String]
|
58
|
+
# HTTP request body. A request body is allowed only if the HTTP
|
59
|
+
# method is POST, PUT, or PATCH. It is an error to set body on a job with an
|
60
|
+
# incompatible {Google::Cloud::Scheduler::V1beta1::HttpMethod HttpMethod}.
|
61
|
+
class HttpTarget; end
|
62
|
+
|
63
|
+
# App Engine target. The job will be pushed to a job handler by means
|
64
|
+
# of an HTTP request via an {Google::Cloud::Scheduler::V1beta1::AppEngineHttpTarget#http_method http_method} such
|
65
|
+
# as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an
|
66
|
+
# HTTP response code in the range [200 - 299]. Error 503 is
|
67
|
+
# considered an App Engine system error instead of an application
|
68
|
+
# error. Requests returning error 503 will be retried regardless of
|
69
|
+
# retry configuration and not counted against retry counts. Any other
|
70
|
+
# response code, or a failure to receive a response before the
|
71
|
+
# deadline, constitutes a failed attempt.
|
72
|
+
# @!attribute [rw] http_method
|
73
|
+
# @return [Google::Cloud::Scheduler::V1beta1::HttpMethod]
|
74
|
+
# The HTTP method to use for the request. PATCH and OPTIONS are not
|
75
|
+
# permitted.
|
76
|
+
# @!attribute [rw] app_engine_routing
|
77
|
+
# @return [Google::Cloud::Scheduler::V1beta1::AppEngineRouting]
|
78
|
+
# App Engine Routing setting for the job.
|
79
|
+
# @!attribute [rw] relative_uri
|
80
|
+
# @return [String]
|
81
|
+
# The relative URI.
|
82
|
+
#
|
83
|
+
# The relative URL must begin with "/" and must be a valid HTTP relative URL.
|
84
|
+
# It can contain a path, query string arguments, and `#` fragments.
|
85
|
+
# If the relative URL is empty, then the root path "/" will be used.
|
86
|
+
# No spaces are allowed, and the maximum length allowed is 2083 characters.
|
87
|
+
# @!attribute [rw] headers
|
88
|
+
# @return [Hash{String => String}]
|
89
|
+
# HTTP request headers.
|
90
|
+
#
|
91
|
+
# This map contains the header field names and values. Headers can be set
|
92
|
+
# when the job is created.
|
93
|
+
#
|
94
|
+
# Cloud Scheduler sets some headers to default values:
|
95
|
+
#
|
96
|
+
# * `User-Agent`: By default, this header is
|
97
|
+
# `"AppEngine-Google; (+http://code.google.com/appengine)"`.
|
98
|
+
# This header can be modified, but Cloud Scheduler will append
|
99
|
+
# `"AppEngine-Google; (+http://code.google.com/appengine)"` to the
|
100
|
+
# modified `User-Agent`.
|
101
|
+
#
|
102
|
+
# If the job has an {Google::Cloud::Scheduler::V1beta1::AppEngineHttpTarget#body body}, Cloud Scheduler sets the
|
103
|
+
# following headers:
|
104
|
+
#
|
105
|
+
# * `Content-Type`: By default, the `Content-Type` header is set to
|
106
|
+
# `"application/octet-stream"`. The default can be overridden by explictly
|
107
|
+
# setting `Content-Type` to a particular media type when the job is
|
108
|
+
# created.
|
109
|
+
# For example, `Content-Type` can be set to `"application/json"`.
|
110
|
+
# * `Content-Length`: This is computed by Cloud Scheduler. This value is
|
111
|
+
# output only. It cannot be changed.
|
112
|
+
#
|
113
|
+
# The headers below are output only. They cannot be set or overridden:
|
114
|
+
#
|
115
|
+
# * `X-Google-*`: For Google internal use only.
|
116
|
+
# * `X-AppEngine-*`: For Google internal use only. See
|
117
|
+
# [Reading request headers](https://cloud.google.com/appengine/docs/python/taskqueue/push/creating-handlers#reading_request_headers).
|
118
|
+
#
|
119
|
+
# In addition, some App Engine headers, which contain
|
120
|
+
# job-specific information, are also be sent to the job handler; see
|
121
|
+
# [request headers](https://cloud.google.comappengine/docs/standard/python/config/cron#securing_urls_for_cron).
|
122
|
+
# @!attribute [rw] body
|
123
|
+
# @return [String]
|
124
|
+
# Body.
|
125
|
+
#
|
126
|
+
# HTTP request body. A request body is allowed only if the HTTP method is
|
127
|
+
# POST or PUT. It will result in invalid argument error to set a body on a
|
128
|
+
# job with an incompatible {Google::Cloud::Scheduler::V1beta1::HttpMethod HttpMethod}.
|
129
|
+
class AppEngineHttpTarget; end
|
130
|
+
|
131
|
+
# Pub/Sub target. The job will be delivered by publishing a message to
|
132
|
+
# the given Pub/Sub topic.
|
133
|
+
# @!attribute [rw] topic_name
|
134
|
+
# @return [String]
|
135
|
+
# Required.
|
136
|
+
#
|
137
|
+
# The name of the Cloud Pub/Sub topic to which messages will
|
138
|
+
# be published when a job is delivered. The topic name must be in the
|
139
|
+
# same format as required by PubSub's
|
140
|
+
# [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest),
|
141
|
+
# for example `projects/PROJECT_ID/topics/TOPIC_ID`.
|
142
|
+
#
|
143
|
+
# The topic must be in the same project as the Cloud Scheduler job.
|
144
|
+
# @!attribute [rw] data
|
145
|
+
# @return [String]
|
146
|
+
# The message payload for PubsubMessage.
|
147
|
+
#
|
148
|
+
# Pubsub message must contain either non-empty data, or at least one
|
149
|
+
# attribute.
|
150
|
+
# @!attribute [rw] attributes
|
151
|
+
# @return [Hash{String => String}]
|
152
|
+
# Attributes for PubsubMessage.
|
153
|
+
#
|
154
|
+
# Pubsub message must contain either non-empty data, or at least one
|
155
|
+
# attribute.
|
156
|
+
class PubsubTarget; end
|
157
|
+
|
158
|
+
# App Engine Routing.
|
159
|
+
#
|
160
|
+
# For more information about services, versions, and instances see
|
161
|
+
# [An Overview of App Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine),
|
162
|
+
# [Microservices Architecture on Google App Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine),
|
163
|
+
# [App Engine Standard request routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), and
|
164
|
+
# [App Engine Flex request routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
|
165
|
+
# @!attribute [rw] service
|
166
|
+
# @return [String]
|
167
|
+
# App service.
|
168
|
+
#
|
169
|
+
# By default, the job is sent to the service which is the default
|
170
|
+
# service when the job is attempted.
|
171
|
+
# @!attribute [rw] version
|
172
|
+
# @return [String]
|
173
|
+
# App version.
|
174
|
+
#
|
175
|
+
# By default, the job is sent to the version which is the default
|
176
|
+
# version when the job is attempted.
|
177
|
+
# @!attribute [rw] instance
|
178
|
+
# @return [String]
|
179
|
+
# App instance.
|
180
|
+
#
|
181
|
+
# By default, the job is sent to an instance which is available when
|
182
|
+
# the job is attempted.
|
183
|
+
#
|
184
|
+
# Requests can only be sent to a specific instance if
|
185
|
+
# [manual scaling is used in App Engine Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes).
|
186
|
+
# App Engine Flex does not support instances. For more information, see
|
187
|
+
# [App Engine Standard request routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) and
|
188
|
+
# [App Engine Flex request routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
|
189
|
+
# @!attribute [rw] host
|
190
|
+
# @return [String]
|
191
|
+
# Output only. The host that the job is sent to.
|
192
|
+
#
|
193
|
+
# For more information about how App Engine requests are routed, see
|
194
|
+
# [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed).
|
195
|
+
#
|
196
|
+
# The host is constructed as:
|
197
|
+
#
|
198
|
+
#
|
199
|
+
# * `host = [application_domain_name]`</br>
|
200
|
+
# `| [service] + '.' + [application_domain_name]`</br>
|
201
|
+
# `| [version] + '.' + [application_domain_name]`</br>
|
202
|
+
# `| [version_dot_service]+ '.' + [application_domain_name]`</br>
|
203
|
+
# `| [instance] + '.' + [application_domain_name]`</br>
|
204
|
+
# `| [instance_dot_service] + '.' + [application_domain_name]`</br>
|
205
|
+
# `| [instance_dot_version] + '.' + [application_domain_name]`</br>
|
206
|
+
# `| [instance_dot_version_dot_service] + '.' + [application_domain_name]`
|
207
|
+
#
|
208
|
+
# * `application_domain_name` = The domain name of the app, for
|
209
|
+
# example <app-id>.appspot.com, which is associated with the
|
210
|
+
# job's project ID.
|
211
|
+
#
|
212
|
+
# * `service =` {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#service service}
|
213
|
+
#
|
214
|
+
# * `version =` {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#version version}
|
215
|
+
#
|
216
|
+
# * `version_dot_service =`
|
217
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#version version} `+ '.' +`
|
218
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#service service}
|
219
|
+
#
|
220
|
+
# * `instance =` {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#instance instance}
|
221
|
+
#
|
222
|
+
# * `instance_dot_service =`
|
223
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#instance instance} `+ '.' +`
|
224
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#service service}
|
225
|
+
#
|
226
|
+
# * `instance_dot_version =`
|
227
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#instance instance} `+ '.' +`
|
228
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#version version}
|
229
|
+
#
|
230
|
+
# * `instance_dot_version_dot_service =`
|
231
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#instance instance} `+ '.' +`
|
232
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#version version} `+ '.' +`
|
233
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#service service}
|
234
|
+
#
|
235
|
+
#
|
236
|
+
# If {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#service service} is empty, then the job will be sent
|
237
|
+
# to the service which is the default service when the job is attempted.
|
238
|
+
#
|
239
|
+
# If {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#version version} is empty, then the job will be sent
|
240
|
+
# to the version which is the default version when the job is attempted.
|
241
|
+
#
|
242
|
+
# If {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#instance instance} is empty, then the job will be
|
243
|
+
# sent to an instance which is available when the job is attempted.
|
244
|
+
#
|
245
|
+
# If {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#service service},
|
246
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#version version}, or
|
247
|
+
# {Google::Cloud::Scheduler::V1beta1::AppEngineRouting#instance instance} is invalid, then the job will be sent
|
248
|
+
# to the default version of the default service when the job is attempted.
|
249
|
+
class AppEngineRouting; end
|
250
|
+
|
251
|
+
# The HTTP method used to execute the job.
|
252
|
+
module HttpMethod
|
253
|
+
# HTTP method unspecified. Defaults to POST.
|
254
|
+
HTTP_METHOD_UNSPECIFIED = 0
|
255
|
+
|
256
|
+
# HTTP POST
|
257
|
+
POST = 1
|
258
|
+
|
259
|
+
# HTTP GET
|
260
|
+
GET = 2
|
261
|
+
|
262
|
+
# HTTP HEAD
|
263
|
+
HEAD = 3
|
264
|
+
|
265
|
+
# HTTP PUT
|
266
|
+
PUT = 4
|
267
|
+
|
268
|
+
# HTTP DELETE
|
269
|
+
DELETE = 5
|
270
|
+
|
271
|
+
# HTTP PATCH
|
272
|
+
PATCH = 6
|
273
|
+
|
274
|
+
# HTTP OPTIONS
|
275
|
+
OPTIONS = 7
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Protobuf
|
18
|
+
# `Any` contains an arbitrary serialized protocol buffer message along with a
|
19
|
+
# URL that describes the type of the serialized message.
|
20
|
+
#
|
21
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
22
|
+
# of utility functions or additional generated methods of the Any type.
|
23
|
+
#
|
24
|
+
# Example 1: Pack and unpack a message in C++.
|
25
|
+
#
|
26
|
+
# Foo foo = ...;
|
27
|
+
# Any any;
|
28
|
+
# any.PackFrom(foo);
|
29
|
+
# ...
|
30
|
+
# if (any.UnpackTo(&foo)) {
|
31
|
+
# ...
|
32
|
+
# }
|
33
|
+
#
|
34
|
+
# Example 2: Pack and unpack a message in Java.
|
35
|
+
#
|
36
|
+
# Foo foo = ...;
|
37
|
+
# Any any = Any.pack(foo);
|
38
|
+
# ...
|
39
|
+
# if (any.is(Foo.class)) {
|
40
|
+
# foo = any.unpack(Foo.class);
|
41
|
+
# }
|
42
|
+
#
|
43
|
+
# Example 3: Pack and unpack a message in Python.
|
44
|
+
#
|
45
|
+
# foo = Foo(...)
|
46
|
+
# any = Any()
|
47
|
+
# any.Pack(foo)
|
48
|
+
# ...
|
49
|
+
# if any.Is(Foo.DESCRIPTOR):
|
50
|
+
# any.Unpack(foo)
|
51
|
+
# ...
|
52
|
+
#
|
53
|
+
# Example 4: Pack and unpack a message in Go
|
54
|
+
#
|
55
|
+
# foo := &pb.Foo{...}
|
56
|
+
# any, err := ptypes.MarshalAny(foo)
|
57
|
+
# ...
|
58
|
+
# foo := &pb.Foo{}
|
59
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
60
|
+
# ...
|
61
|
+
# }
|
62
|
+
#
|
63
|
+
# The pack methods provided by protobuf library will by default use
|
64
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
65
|
+
# methods only use the fully qualified type name after the last '/'
|
66
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
67
|
+
# name "y.z".
|
68
|
+
#
|
69
|
+
#
|
70
|
+
# = JSON
|
71
|
+
#
|
72
|
+
# The JSON representation of an `Any` value uses the regular
|
73
|
+
# representation of the deserialized, embedded message, with an
|
74
|
+
# additional field `@type` which contains the type URL. Example:
|
75
|
+
#
|
76
|
+
# package google.profile;
|
77
|
+
# message Person {
|
78
|
+
# string first_name = 1;
|
79
|
+
# string last_name = 2;
|
80
|
+
# }
|
81
|
+
#
|
82
|
+
# {
|
83
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
84
|
+
# "firstName": <string>,
|
85
|
+
# "lastName": <string>
|
86
|
+
# }
|
87
|
+
#
|
88
|
+
# If the embedded message type is well-known and has a custom JSON
|
89
|
+
# representation, that representation will be embedded adding a field
|
90
|
+
# `value` which holds the custom JSON in addition to the `@type`
|
91
|
+
# field. Example (for message {Google::Protobuf::Duration}):
|
92
|
+
#
|
93
|
+
# {
|
94
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
95
|
+
# "value": "1.212s"
|
96
|
+
# }
|
97
|
+
# @!attribute [rw] type_url
|
98
|
+
# @return [String]
|
99
|
+
# A URL/resource name that uniquely identifies the type of the serialized
|
100
|
+
# protocol buffer message. The last segment of the URL's path must represent
|
101
|
+
# the fully qualified name of the type (as in
|
102
|
+
# `path/google.protobuf.Duration`). The name should be in a canonical form
|
103
|
+
# (e.g., leading "." is not accepted).
|
104
|
+
#
|
105
|
+
# In practice, teams usually precompile into the binary all types that they
|
106
|
+
# expect it to use in the context of Any. However, for URLs which use the
|
107
|
+
# scheme `http`, `https`, or no scheme, one can optionally set up a type
|
108
|
+
# server that maps type URLs to message definitions as follows:
|
109
|
+
#
|
110
|
+
# * If no scheme is provided, `https` is assumed.
|
111
|
+
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
112
|
+
# value in binary format, or produce an error.
|
113
|
+
# * Applications are allowed to cache lookup results based on the
|
114
|
+
# URL, or have them precompiled into a binary to avoid any
|
115
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
116
|
+
# on changes to types. (Use versioned type names to manage
|
117
|
+
# breaking changes.)
|
118
|
+
#
|
119
|
+
# Note: this functionality is not currently available in the official
|
120
|
+
# protobuf release, and it is not used for type URLs beginning with
|
121
|
+
# type.googleapis.com.
|
122
|
+
#
|
123
|
+
# Schemes other than `http`, `https` (or the empty scheme) might be
|
124
|
+
# used with implementation specific semantics.
|
125
|
+
# @!attribute [rw] value
|
126
|
+
# @return [String]
|
127
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
128
|
+
class Any; end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Protobuf
|
18
|
+
# A Duration represents a signed, fixed-length span of time represented
|
19
|
+
# as a count of seconds and fractions of seconds at nanosecond
|
20
|
+
# resolution. It is independent of any calendar and concepts like "day"
|
21
|
+
# or "month". It is related to Timestamp in that the difference between
|
22
|
+
# two Timestamp values is a Duration and it can be added or subtracted
|
23
|
+
# from a Timestamp. Range is approximately +-10,000 years.
|
24
|
+
#
|
25
|
+
# = Examples
|
26
|
+
#
|
27
|
+
# Example 1: Compute Duration from two Timestamps in pseudo code.
|
28
|
+
#
|
29
|
+
# Timestamp start = ...;
|
30
|
+
# Timestamp end = ...;
|
31
|
+
# Duration duration = ...;
|
32
|
+
#
|
33
|
+
# duration.seconds = end.seconds - start.seconds;
|
34
|
+
# duration.nanos = end.nanos - start.nanos;
|
35
|
+
#
|
36
|
+
# if (duration.seconds < 0 && duration.nanos > 0) {
|
37
|
+
# duration.seconds += 1;
|
38
|
+
# duration.nanos -= 1000000000;
|
39
|
+
# } else if (durations.seconds > 0 && duration.nanos < 0) {
|
40
|
+
# duration.seconds -= 1;
|
41
|
+
# duration.nanos += 1000000000;
|
42
|
+
# }
|
43
|
+
#
|
44
|
+
# Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
45
|
+
#
|
46
|
+
# Timestamp start = ...;
|
47
|
+
# Duration duration = ...;
|
48
|
+
# Timestamp end = ...;
|
49
|
+
#
|
50
|
+
# end.seconds = start.seconds + duration.seconds;
|
51
|
+
# end.nanos = start.nanos + duration.nanos;
|
52
|
+
#
|
53
|
+
# if (end.nanos < 0) {
|
54
|
+
# end.seconds -= 1;
|
55
|
+
# end.nanos += 1000000000;
|
56
|
+
# } else if (end.nanos >= 1000000000) {
|
57
|
+
# end.seconds += 1;
|
58
|
+
# end.nanos -= 1000000000;
|
59
|
+
# }
|
60
|
+
#
|
61
|
+
# Example 3: Compute Duration from datetime.timedelta in Python.
|
62
|
+
#
|
63
|
+
# td = datetime.timedelta(days=3, minutes=10)
|
64
|
+
# duration = Duration()
|
65
|
+
# duration.FromTimedelta(td)
|
66
|
+
#
|
67
|
+
# = JSON Mapping
|
68
|
+
#
|
69
|
+
# In JSON format, the Duration type is encoded as a string rather than an
|
70
|
+
# object, where the string ends in the suffix "s" (indicating seconds) and
|
71
|
+
# is preceded by the number of seconds, with nanoseconds expressed as
|
72
|
+
# fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
73
|
+
# encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
74
|
+
# be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
75
|
+
# microsecond should be expressed in JSON format as "3.000001s".
|
76
|
+
# @!attribute [rw] seconds
|
77
|
+
# @return [Integer]
|
78
|
+
# Signed seconds of the span of time. Must be from -315,576,000,000
|
79
|
+
# to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
80
|
+
# 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
81
|
+
# @!attribute [rw] nanos
|
82
|
+
# @return [Integer]
|
83
|
+
# Signed fractions of a second at nanosecond resolution of the span
|
84
|
+
# of time. Durations less than one second are represented with a 0
|
85
|
+
# `seconds` field and a positive or negative `nanos` field. For durations
|
86
|
+
# of one second or more, a non-zero value for the `nanos` field must be
|
87
|
+
# of the same sign as the `seconds` field. Must be from -999,999,999
|
88
|
+
# to +999,999,999 inclusive.
|
89
|
+
class Duration; end
|
90
|
+
end
|
91
|
+
end
|