google-cloud-scheduler 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/scheduler.rb +3 -3
  4. data/lib/google/cloud/scheduler/v1.rb +139 -0
  5. data/lib/google/cloud/scheduler/v1/cloud_scheduler_client.rb +612 -0
  6. data/lib/google/cloud/scheduler/v1/cloud_scheduler_client_config.json +66 -0
  7. data/lib/google/cloud/scheduler/v1/cloudscheduler_pb.rb +62 -0
  8. data/lib/google/cloud/scheduler/v1/cloudscheduler_services_pb.rb +84 -0
  9. data/lib/google/cloud/scheduler/v1/credentials.rb +41 -0
  10. data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/cloudscheduler.rb +142 -0
  11. data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/job.rb +207 -0
  12. data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/target.rb +286 -0
  13. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/any.rb +130 -0
  14. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/duration.rb +91 -0
  15. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/empty.rb +29 -0
  16. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/field_mask.rb +230 -0
  17. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/timestamp.rb +109 -0
  18. data/lib/google/cloud/scheduler/v1/doc/google/rpc/status.rb +87 -0
  19. data/lib/google/cloud/scheduler/v1/helpers.rb +48 -0
  20. data/lib/google/cloud/scheduler/v1/job_pb.rb +56 -0
  21. data/lib/google/cloud/scheduler/v1/target_pb.rb +58 -0
  22. data/lib/google/cloud/scheduler/v1beta1.rb +1 -1
  23. data/lib/google/cloud/scheduler/v1beta1/cloud_scheduler_client.rb +28 -16
  24. data/lib/google/cloud/scheduler/v1beta1/cloudscheduler_services_pb.rb +23 -13
  25. data/lib/google/cloud/scheduler/v1beta1/credentials.rb +1 -1
  26. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/cloudscheduler.rb +31 -18
  27. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/job.rb +37 -25
  28. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/target.rb +62 -42
  29. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/any.rb +1 -1
  30. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/duration.rb +1 -1
  31. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/empty.rb +1 -1
  32. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/field_mask.rb +1 -1
  33. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/timestamp.rb +1 -1
  34. data/lib/google/cloud/scheduler/v1beta1/doc/google/rpc/status.rb +18 -15
  35. data/lib/google/cloud/scheduler/v1beta1/helpers.rb +7 -7
  36. metadata +23 -5
@@ -0,0 +1,286 @@
1
+ # Copyright 2019 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 V1
20
+ # Http target. The job will be pushed to the job handler by means of
21
+ # an HTTP request via an {Google::Cloud::Scheduler::V1::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::V1::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::V1::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::V1::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::V1::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::V1::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::V1::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::V1::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
+ # * `X-CloudScheduler`: This header will be set to true.
102
+ #
103
+ # If the job has an {Google::Cloud::Scheduler::V1::AppEngineHttpTarget#body body}, Cloud Scheduler sets
104
+ # the following headers:
105
+ #
106
+ # * `Content-Type`: By default, the `Content-Type` header is set to
107
+ # `"application/octet-stream"`. The default can be overridden by explictly
108
+ # setting `Content-Type` to a particular media type when the job is
109
+ # created.
110
+ # For example, `Content-Type` can be set to `"application/json"`.
111
+ # * `Content-Length`: This is computed by Cloud Scheduler. This value is
112
+ # output only. It cannot be changed.
113
+ #
114
+ # The headers below are output only. They cannot be set or overridden:
115
+ #
116
+ # * `X-Google-*`: For Google internal use only.
117
+ # * `X-AppEngine-*`: For Google internal use only.
118
+ #
119
+ # In addition, some App Engine headers, which contain
120
+ # job-specific information, are also be sent to the job handler.
121
+ # @!attribute [rw] body
122
+ # @return [String]
123
+ # Body.
124
+ #
125
+ # HTTP request body. A request body is allowed only if the HTTP method is
126
+ # POST or PUT. It will result in invalid argument error to set a body on a
127
+ # job with an incompatible {Google::Cloud::Scheduler::V1::HttpMethod HttpMethod}.
128
+ class AppEngineHttpTarget; end
129
+
130
+ # Pub/Sub target. The job will be delivered by publishing a message to
131
+ # the given Pub/Sub topic.
132
+ # @!attribute [rw] topic_name
133
+ # @return [String]
134
+ # Required.
135
+ #
136
+ # The name of the Cloud Pub/Sub topic to which messages will
137
+ # be published when a job is delivered. The topic name must be in the
138
+ # same format as required by PubSub's
139
+ # [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest),
140
+ # for example `projects/PROJECT_ID/topics/TOPIC_ID`.
141
+ #
142
+ # The topic must be in the same project as the Cloud Scheduler job.
143
+ # @!attribute [rw] data
144
+ # @return [String]
145
+ # The message payload for PubsubMessage.
146
+ #
147
+ # Pubsub message must contain either non-empty data, or at least one
148
+ # attribute.
149
+ # @!attribute [rw] attributes
150
+ # @return [Hash{String => String}]
151
+ # Attributes for PubsubMessage.
152
+ #
153
+ # Pubsub message must contain either non-empty data, or at least one
154
+ # attribute.
155
+ class PubsubTarget; end
156
+
157
+ # App Engine Routing.
158
+ #
159
+ # For more information about services, versions, and instances see
160
+ # [An Overview of App
161
+ # Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine),
162
+ # [Microservices Architecture on Google App
163
+ # Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine),
164
+ # [App Engine Standard request
165
+ # routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed),
166
+ # and [App Engine Flex request
167
+ # routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
168
+ # @!attribute [rw] service
169
+ # @return [String]
170
+ # App service.
171
+ #
172
+ # By default, the job is sent to the service which is the default
173
+ # service when the job is attempted.
174
+ # @!attribute [rw] version
175
+ # @return [String]
176
+ # App version.
177
+ #
178
+ # By default, the job is sent to the version which is the default
179
+ # version when the job is attempted.
180
+ # @!attribute [rw] instance
181
+ # @return [String]
182
+ # App instance.
183
+ #
184
+ # By default, the job is sent to an instance which is available when
185
+ # the job is attempted.
186
+ #
187
+ # Requests can only be sent to a specific instance if
188
+ # [manual scaling is used in App Engine
189
+ # Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes).
190
+ # App Engine Flex does not support instances. For more information, see
191
+ # [App Engine Standard request
192
+ # routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed)
193
+ # and [App Engine Flex request
194
+ # routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
195
+ # @!attribute [rw] host
196
+ # @return [String]
197
+ # Output only. The host that the job is sent to.
198
+ #
199
+ # For more information about how App Engine requests are routed, see
200
+ # [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed).
201
+ #
202
+ # The host is constructed as:
203
+ #
204
+ #
205
+ # * `host = [application_domain_name]`</br>
206
+ # `| [service] + '.' + [application_domain_name]`</br>
207
+ # `| [version] + '.' + [application_domain_name]`</br>
208
+ # `| [version_dot_service]+ '.' + [application_domain_name]`</br>
209
+ # `| [instance] + '.' + [application_domain_name]`</br>
210
+ # `| [instance_dot_service] + '.' + [application_domain_name]`</br>
211
+ # `| [instance_dot_version] + '.' + [application_domain_name]`</br>
212
+ # `| [instance_dot_version_dot_service] + '.' + [application_domain_name]`
213
+ #
214
+ # * `application_domain_name` = The domain name of the app, for
215
+ # example <app-id>.appspot.com, which is associated with the
216
+ # job's project ID.
217
+ #
218
+ # * `service =` {Google::Cloud::Scheduler::V1::AppEngineRouting#service service}
219
+ #
220
+ # * `version =` {Google::Cloud::Scheduler::V1::AppEngineRouting#version version}
221
+ #
222
+ # * `version_dot_service =`
223
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#version version} `+ '.' +`
224
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#service service}
225
+ #
226
+ # * `instance =` {Google::Cloud::Scheduler::V1::AppEngineRouting#instance instance}
227
+ #
228
+ # * `instance_dot_service =`
229
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#instance instance} `+ '.' +`
230
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#service service}
231
+ #
232
+ # * `instance_dot_version =`
233
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#instance instance} `+ '.' +`
234
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#version version}
235
+ #
236
+ # * `instance_dot_version_dot_service =`
237
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#instance instance} `+ '.' +`
238
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#version version} `+ '.' +`
239
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#service service}
240
+ #
241
+ #
242
+ # If {Google::Cloud::Scheduler::V1::AppEngineRouting#service service} is empty, then the job will be sent
243
+ # to the service which is the default service when the job is attempted.
244
+ #
245
+ # If {Google::Cloud::Scheduler::V1::AppEngineRouting#version version} is empty, then the job will be sent
246
+ # to the version which is the default version when the job is attempted.
247
+ #
248
+ # If {Google::Cloud::Scheduler::V1::AppEngineRouting#instance instance} is empty, then the job will be
249
+ # sent to an instance which is available when the job is attempted.
250
+ #
251
+ # If {Google::Cloud::Scheduler::V1::AppEngineRouting#service service},
252
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#version version}, or
253
+ # {Google::Cloud::Scheduler::V1::AppEngineRouting#instance instance} is invalid, then the job will be sent
254
+ # to the default version of the default service when the job is attempted.
255
+ class AppEngineRouting; end
256
+
257
+ # The HTTP method used to execute the job.
258
+ module HttpMethod
259
+ # HTTP method unspecified. Defaults to POST.
260
+ HTTP_METHOD_UNSPECIFIED = 0
261
+
262
+ # HTTP POST
263
+ POST = 1
264
+
265
+ # HTTP GET
266
+ GET = 2
267
+
268
+ # HTTP HEAD
269
+ HEAD = 3
270
+
271
+ # HTTP PUT
272
+ PUT = 4
273
+
274
+ # HTTP DELETE
275
+ DELETE = 5
276
+
277
+ # HTTP PATCH
278
+ PATCH = 6
279
+
280
+ # HTTP OPTIONS
281
+ OPTIONS = 7
282
+ end
283
+ end
284
+ end
285
+ end
286
+ end
@@ -0,0 +1,130 @@
1
+ # Copyright 2019 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 2019 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