google-cloud-tasks 0.1.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.
- checksums.yaml +7 -0
- data/.yardopts +8 -0
- data/LICENSE +201 -0
- data/README.md +32 -0
- data/lib/google/cloud/tasks.rb +106 -0
- data/lib/google/cloud/tasks/credentials.rb +30 -0
- data/lib/google/cloud/tasks/v2beta2.rb +99 -0
- data/lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb +1446 -0
- data/lib/google/cloud/tasks/v2beta2/cloud_tasks_client_config.json +126 -0
- data/lib/google/cloud/tasks/v2beta2/cloudtasks_pb.rb +130 -0
- data/lib/google/cloud/tasks/v2beta2/cloudtasks_services_pb.rb +258 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/cloud/tasks/v2beta2/queue.rb +329 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/cloud/tasks/v2beta2/target.rb +346 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/cloud/tasks/v2beta2/task.rb +167 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/iam/v1/policy.rb +127 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/protobuf/duration.rb +90 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/protobuf/field_mask.rb +223 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/protobuf/timestamp.rb +106 -0
- data/lib/google/cloud/tasks/v2beta2/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/tasks/v2beta2/doc/overview.rb +55 -0
- data/lib/google/cloud/tasks/v2beta2/queue_pb.rb +56 -0
- data/lib/google/cloud/tasks/v2beta2/target_pb.rb +54 -0
- data/lib/google/cloud/tasks/v2beta2/task_pb.rb +52 -0
- metadata +136 -0
@@ -0,0 +1,167 @@
|
|
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
|
+
module Google
|
16
|
+
module Cloud
|
17
|
+
module Tasks
|
18
|
+
module V2beta2
|
19
|
+
# A unit of scheduled work.
|
20
|
+
# @!attribute [rw] name
|
21
|
+
# @return [String]
|
22
|
+
# The task name.
|
23
|
+
#
|
24
|
+
# The task name must have the following format:
|
25
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
|
26
|
+
#
|
27
|
+
# * +PROJECT_ID+ can contain letters ([A-Za-z]), numbers ([0-9]),
|
28
|
+
# hyphens (-), colons (:), or periods (.).
|
29
|
+
# For more information, see
|
30
|
+
# [Identifying projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
|
31
|
+
# * +LOCATION_ID+ is the canonical ID for the task's location.
|
32
|
+
# The list of available locations can be obtained by calling
|
33
|
+
# {Google::Cloud::Location::Locations::ListLocations ListLocations}.
|
34
|
+
# For more information, see https://cloud.google.com/about/locations/.
|
35
|
+
# * +QUEUE_ID+ can contain letters ([A-Za-z]), numbers ([0-9]), or
|
36
|
+
# hyphens (-). The maximum length is 100 characters.
|
37
|
+
# * +TASK_ID+ can contain only letters ([A-Za-z]), numbers ([0-9]),
|
38
|
+
# hyphens (-), or underscores (_). The maximum length is 500 characters.
|
39
|
+
#
|
40
|
+
# Optionally caller-specified in {Google::Cloud::Tasks::V2beta2::CloudTasks::CreateTask CreateTask}.
|
41
|
+
# @!attribute [rw] app_engine_http_request
|
42
|
+
# @return [Google::Cloud::Tasks::V2beta2::AppEngineHttpRequest]
|
43
|
+
# App Engine HTTP request that is sent to the task's target. Can
|
44
|
+
# be set only if
|
45
|
+
# {Google::Cloud::Tasks::V2beta2::Queue#app_engine_http_target app_engine_http_target} is set
|
46
|
+
# on the queue.
|
47
|
+
#
|
48
|
+
# An App Engine task is a task that has {Google::Cloud::Tasks::V2beta2::AppEngineHttpRequest AppEngineHttpRequest} set.
|
49
|
+
# @!attribute [rw] pull_message
|
50
|
+
# @return [Google::Cloud::Tasks::V2beta2::PullMessage]
|
51
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} to process the task. Can be
|
52
|
+
# set only if {Google::Cloud::Tasks::V2beta2::Queue#pull_target pull_target} is set on the queue.
|
53
|
+
#
|
54
|
+
# A pull task is a task that has {Google::Cloud::Tasks::V2beta2::PullMessage PullMessage} set.
|
55
|
+
# @!attribute [rw] schedule_time
|
56
|
+
# @return [Google::Protobuf::Timestamp]
|
57
|
+
# The time when the task is scheduled to be attempted.
|
58
|
+
#
|
59
|
+
# For App Engine queues, this is when the task will be attempted or retried.
|
60
|
+
#
|
61
|
+
# For pull queues, this is the time when the task is available to
|
62
|
+
# be leased; if a task is currently leased, this is the time when
|
63
|
+
# the current lease expires, that is, the time that the task was
|
64
|
+
# leased plus the {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration}.
|
65
|
+
#
|
66
|
+
# +schedule_time+ will be truncated to the nearest microsecond.
|
67
|
+
# @!attribute [rw] create_time
|
68
|
+
# @return [Google::Protobuf::Timestamp]
|
69
|
+
# Output only. The time that the task was created.
|
70
|
+
#
|
71
|
+
# +create_time+ will be truncated to the nearest second.
|
72
|
+
# @!attribute [rw] status
|
73
|
+
# @return [Google::Cloud::Tasks::V2beta2::TaskStatus]
|
74
|
+
# Output only. The task status.
|
75
|
+
# @!attribute [rw] view
|
76
|
+
# @return [Google::Cloud::Tasks::V2beta2::Task::View]
|
77
|
+
# Output only. The view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} has
|
78
|
+
# been returned.
|
79
|
+
class Task
|
80
|
+
# The view specifies a subset of {Google::Cloud::Tasks::V2beta2::Task Task} data.
|
81
|
+
#
|
82
|
+
# When a task is returned in a response, not all
|
83
|
+
# information is retrieved by default because some data, such as
|
84
|
+
# payloads, might be desirable to return only when needed because
|
85
|
+
# of its large size or because of the sensitivity of data that it
|
86
|
+
# contains.
|
87
|
+
module View
|
88
|
+
# Unspecified. Defaults to BASIC.
|
89
|
+
VIEW_UNSPECIFIED = 0
|
90
|
+
|
91
|
+
# The basic view omits fields which can be large or can contain
|
92
|
+
# sensitive data.
|
93
|
+
#
|
94
|
+
# This view does not include the
|
95
|
+
# ({Google::Cloud::Tasks::V2beta2::AppEngineHttpRequest payload in AppEngineHttpRequest} and
|
96
|
+
# {Google::Cloud::Tasks::V2beta2::PullMessage#payload payload in PullMessage}). These payloads are
|
97
|
+
# desirable to return only when needed, because they can be large
|
98
|
+
# and because of the sensitivity of the data that you choose to
|
99
|
+
# store in it.
|
100
|
+
BASIC = 1
|
101
|
+
|
102
|
+
# All information is returned.
|
103
|
+
#
|
104
|
+
# Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
|
105
|
+
# +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/)
|
106
|
+
# permission on the {Google::Cloud::Tasks::V2beta2::Queue Queue} resource.
|
107
|
+
FULL = 2
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Status of the task.
|
112
|
+
# @!attribute [rw] attempt_dispatch_count
|
113
|
+
# @return [Integer]
|
114
|
+
# Output only. The number of attempts dispatched.
|
115
|
+
#
|
116
|
+
# This count includes tasks which have been dispatched but haven't
|
117
|
+
# received a response.
|
118
|
+
# @!attribute [rw] attempt_response_count
|
119
|
+
# @return [Integer]
|
120
|
+
# Output only. The number of attempts which have received a response.
|
121
|
+
#
|
122
|
+
# This field is not calculated for
|
123
|
+
# [pull tasks](https://cloud.google.comgoogle.cloud.tasks.v2beta2.PullTaskTarget).
|
124
|
+
# @!attribute [rw] first_attempt_status
|
125
|
+
# @return [Google::Cloud::Tasks::V2beta2::AttemptStatus]
|
126
|
+
# Output only. The status of the task's first attempt.
|
127
|
+
#
|
128
|
+
# Only {Google::Cloud::Tasks::V2beta2::AttemptStatus#dispatch_time dispatch_time} will be set.
|
129
|
+
# The other {Google::Cloud::Tasks::V2beta2::AttemptStatus AttemptStatus} information is not retained by Cloud Tasks.
|
130
|
+
#
|
131
|
+
# This field is not calculated for
|
132
|
+
# [pull tasks](https://cloud.google.comgoogle.cloud.tasks.v2beta2.PullTaskTarget).
|
133
|
+
# @!attribute [rw] last_attempt_status
|
134
|
+
# @return [Google::Cloud::Tasks::V2beta2::AttemptStatus]
|
135
|
+
# Output only. The status of the task's last attempt.
|
136
|
+
#
|
137
|
+
# This field is not calculated for
|
138
|
+
# [pull tasks](https://cloud.google.comgoogle.cloud.tasks.v2beta2.PullTaskTarget).
|
139
|
+
class TaskStatus; end
|
140
|
+
|
141
|
+
# The status of a task attempt.
|
142
|
+
# @!attribute [rw] schedule_time
|
143
|
+
# @return [Google::Protobuf::Timestamp]
|
144
|
+
# Output only. The time that this attempt was scheduled.
|
145
|
+
#
|
146
|
+
# +schedule_time+ will be truncated to the nearest microsecond.
|
147
|
+
# @!attribute [rw] dispatch_time
|
148
|
+
# @return [Google::Protobuf::Timestamp]
|
149
|
+
# Output only. The time that this attempt was dispatched.
|
150
|
+
#
|
151
|
+
# +dispatch_time+ will be truncated to the nearest microsecond.
|
152
|
+
# @!attribute [rw] response_time
|
153
|
+
# @return [Google::Protobuf::Timestamp]
|
154
|
+
# Output only. The time that this attempt response was received.
|
155
|
+
#
|
156
|
+
# +response_time+ will be truncated to the nearest microsecond.
|
157
|
+
# @!attribute [rw] response_status
|
158
|
+
# @return [Google::Rpc::Status]
|
159
|
+
# Output only. The response from the target for this attempt.
|
160
|
+
#
|
161
|
+
# If the task has not been attempted or the task is currently running
|
162
|
+
# then the response status is unset.
|
163
|
+
class AttemptStatus; end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,127 @@
|
|
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
|
+
module Google
|
16
|
+
module Iam
|
17
|
+
module V1
|
18
|
+
# Defines an Identity and Access Management (IAM) policy. It is used to
|
19
|
+
# specify access control policies for Cloud Platform resources.
|
20
|
+
#
|
21
|
+
#
|
22
|
+
# A +Policy+ consists of a list of +bindings+. A +Binding+ binds a list of
|
23
|
+
# +members+ to a +role+, where the members can be user accounts, Google groups,
|
24
|
+
# Google domains, and service accounts. A +role+ is a named list of permissions
|
25
|
+
# defined by IAM.
|
26
|
+
#
|
27
|
+
# **Example**
|
28
|
+
#
|
29
|
+
# {
|
30
|
+
# "bindings": [
|
31
|
+
# {
|
32
|
+
# "role": "roles/owner",
|
33
|
+
# "members": [
|
34
|
+
# "user:mike@example.com",
|
35
|
+
# "group:admins@example.com",
|
36
|
+
# "domain:google.com",
|
37
|
+
# "serviceAccount:my-other-app@appspot.gserviceaccount.com",
|
38
|
+
# ]
|
39
|
+
# },
|
40
|
+
# {
|
41
|
+
# "role": "roles/viewer",
|
42
|
+
# "members": ["user:sean@example.com"]
|
43
|
+
# }
|
44
|
+
# ]
|
45
|
+
# }
|
46
|
+
#
|
47
|
+
# For a description of IAM and its features, see the
|
48
|
+
# [IAM developer's guide](https://cloud.google.com/iam).
|
49
|
+
# @!attribute [rw] version
|
50
|
+
# @return [Integer]
|
51
|
+
# Version of the +Policy+. The default version is 0.
|
52
|
+
# @!attribute [rw] bindings
|
53
|
+
# @return [Array<Google::Iam::V1::Binding>]
|
54
|
+
# Associates a list of +members+ to a +role+.
|
55
|
+
# Multiple +bindings+ must not be specified for the same +role+.
|
56
|
+
# +bindings+ with no members will result in an error.
|
57
|
+
# @!attribute [rw] etag
|
58
|
+
# @return [String]
|
59
|
+
# +etag+ is used for optimistic concurrency control as a way to help
|
60
|
+
# prevent simultaneous updates of a policy from overwriting each other.
|
61
|
+
# It is strongly suggested that systems make use of the +etag+ in the
|
62
|
+
# read-modify-write cycle to perform policy updates in order to avoid race
|
63
|
+
# conditions: An +etag+ is returned in the response to +getIamPolicy+, and
|
64
|
+
# systems are expected to put that etag in the request to +setIamPolicy+ to
|
65
|
+
# ensure that their change will be applied to the same version of the policy.
|
66
|
+
#
|
67
|
+
# If no +etag+ is provided in the call to +setIamPolicy+, then the existing
|
68
|
+
# policy is overwritten blindly.
|
69
|
+
class Policy; end
|
70
|
+
|
71
|
+
# Associates +members+ with a +role+.
|
72
|
+
# @!attribute [rw] role
|
73
|
+
# @return [String]
|
74
|
+
# Role that is assigned to +members+.
|
75
|
+
# For example, +roles/viewer+, +roles/editor+, or +roles/owner+.
|
76
|
+
# Required
|
77
|
+
# @!attribute [rw] members
|
78
|
+
# @return [Array<String>]
|
79
|
+
# Specifies the identities requesting access for a Cloud Platform resource.
|
80
|
+
# +members+ can have the following values:
|
81
|
+
#
|
82
|
+
# * +allUsers+: A special identifier that represents anyone who is
|
83
|
+
# on the internet; with or without a Google account.
|
84
|
+
#
|
85
|
+
# * +allAuthenticatedUsers+: A special identifier that represents anyone
|
86
|
+
# who is authenticated with a Google account or a service account.
|
87
|
+
#
|
88
|
+
# * +user:{emailid}+: An email address that represents a specific Google
|
89
|
+
# account. For example, +alice@gmail.com+ or +joe@example.com+.
|
90
|
+
#
|
91
|
+
#
|
92
|
+
# * +serviceAccount:{emailid}+: An email address that represents a service
|
93
|
+
# account. For example, +my-other-app@appspot.gserviceaccount.com+.
|
94
|
+
#
|
95
|
+
# * +group:{emailid}+: An email address that represents a Google group.
|
96
|
+
# For example, +admins@example.com+.
|
97
|
+
#
|
98
|
+
# * +domain:{domain}+: A Google Apps domain name that represents all the
|
99
|
+
# users of that domain. For example, +google.com+ or +example.com+.
|
100
|
+
class Binding; end
|
101
|
+
|
102
|
+
# The difference delta between two policies.
|
103
|
+
# @!attribute [rw] binding_deltas
|
104
|
+
# @return [Array<Google::Iam::V1::BindingDelta>]
|
105
|
+
# The delta for Bindings between two policies.
|
106
|
+
class PolicyDelta; end
|
107
|
+
|
108
|
+
# One delta entry for Binding. Each individual change (only one member in each
|
109
|
+
# entry) to a binding will be a separate entry.
|
110
|
+
# @!attribute [rw] action
|
111
|
+
# @return [Google::Iam::V1::BindingDelta::Action]
|
112
|
+
# The action that was performed on a Binding.
|
113
|
+
# Required
|
114
|
+
# @!attribute [rw] role
|
115
|
+
# @return [String]
|
116
|
+
# Role that is assigned to +members+.
|
117
|
+
# For example, +roles/viewer+, +roles/editor+, or +roles/owner+.
|
118
|
+
# Required
|
119
|
+
# @!attribute [rw] member
|
120
|
+
# @return [String]
|
121
|
+
# A single identity requesting access for a Cloud Platform resource.
|
122
|
+
# Follows the same format of Binding.members.
|
123
|
+
# Required
|
124
|
+
class BindingDelta; end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# +Any+ contains an arbitrary serialized protocol buffer message along with a
|
18
|
+
# URL that describes the type of the serialized message.
|
19
|
+
#
|
20
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
21
|
+
# of utility functions or additional generated methods of the Any type.
|
22
|
+
#
|
23
|
+
# Example 1: Pack and unpack a message in C++.
|
24
|
+
#
|
25
|
+
# Foo foo = ...;
|
26
|
+
# Any any;
|
27
|
+
# any.PackFrom(foo);
|
28
|
+
# ...
|
29
|
+
# if (any.UnpackTo(&foo)) {
|
30
|
+
# ...
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# Example 2: Pack and unpack a message in Java.
|
34
|
+
#
|
35
|
+
# Foo foo = ...;
|
36
|
+
# Any any = Any.pack(foo);
|
37
|
+
# ...
|
38
|
+
# if (any.is(Foo.class)) {
|
39
|
+
# foo = any.unpack(Foo.class);
|
40
|
+
# }
|
41
|
+
#
|
42
|
+
# Example 3: Pack and unpack a message in Python.
|
43
|
+
#
|
44
|
+
# foo = Foo(...)
|
45
|
+
# any = Any()
|
46
|
+
# any.Pack(foo)
|
47
|
+
# ...
|
48
|
+
# if any.Is(Foo.DESCRIPTOR):
|
49
|
+
# any.Unpack(foo)
|
50
|
+
# ...
|
51
|
+
#
|
52
|
+
# Example 4: Pack and unpack a message in Go
|
53
|
+
#
|
54
|
+
# foo := &pb.Foo{...}
|
55
|
+
# any, err := ptypes.MarshalAny(foo)
|
56
|
+
# ...
|
57
|
+
# foo := &pb.Foo{}
|
58
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
59
|
+
# ...
|
60
|
+
# }
|
61
|
+
#
|
62
|
+
# The pack methods provided by protobuf library will by default use
|
63
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
64
|
+
# methods only use the fully qualified type name after the last '/'
|
65
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
66
|
+
# name "y.z".
|
67
|
+
#
|
68
|
+
#
|
69
|
+
# = JSON
|
70
|
+
#
|
71
|
+
# The JSON representation of an +Any+ value uses the regular
|
72
|
+
# representation of the deserialized, embedded message, with an
|
73
|
+
# additional field +@type+ which contains the type URL. Example:
|
74
|
+
#
|
75
|
+
# package google.profile;
|
76
|
+
# message Person {
|
77
|
+
# string first_name = 1;
|
78
|
+
# string last_name = 2;
|
79
|
+
# }
|
80
|
+
#
|
81
|
+
# {
|
82
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
83
|
+
# "firstName": <string>,
|
84
|
+
# "lastName": <string>
|
85
|
+
# }
|
86
|
+
#
|
87
|
+
# If the embedded message type is well-known and has a custom JSON
|
88
|
+
# representation, that representation will be embedded adding a field
|
89
|
+
# +value+ which holds the custom JSON in addition to the +@type+
|
90
|
+
# field. Example (for message {Google::Protobuf::Duration}):
|
91
|
+
#
|
92
|
+
# {
|
93
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
94
|
+
# "value": "1.212s"
|
95
|
+
# }
|
96
|
+
# @!attribute [rw] type_url
|
97
|
+
# @return [String]
|
98
|
+
# A URL/resource name whose content describes the type of the
|
99
|
+
# serialized protocol buffer message.
|
100
|
+
#
|
101
|
+
# For URLs which use the scheme +http+, +https+, or no scheme, the
|
102
|
+
# following restrictions and interpretations apply:
|
103
|
+
#
|
104
|
+
# * If no scheme is provided, +https+ is assumed.
|
105
|
+
# * The last segment of the URL's path must represent the fully
|
106
|
+
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
107
|
+
# The name should be in a canonical form (e.g., leading "." is
|
108
|
+
# not accepted).
|
109
|
+
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
110
|
+
# value in binary format, or produce an error.
|
111
|
+
# * Applications are allowed to cache lookup results based on the
|
112
|
+
# URL, or have them precompiled into a binary to avoid any
|
113
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
114
|
+
# on changes to types. (Use versioned type names to manage
|
115
|
+
# breaking changes.)
|
116
|
+
#
|
117
|
+
# Schemes other than +http+, +https+ (or the empty scheme) might be
|
118
|
+
# used with implementation specific semantics.
|
119
|
+
# @!attribute [rw] value
|
120
|
+
# @return [String]
|
121
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
122
|
+
class Any; end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,90 @@
|
|
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
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# A Duration represents a signed, fixed-length span of time represented
|
18
|
+
# as a count of seconds and fractions of seconds at nanosecond
|
19
|
+
# resolution. It is independent of any calendar and concepts like "day"
|
20
|
+
# or "month". It is related to Timestamp in that the difference between
|
21
|
+
# two Timestamp values is a Duration and it can be added or subtracted
|
22
|
+
# from a Timestamp. Range is approximately +-10,000 years.
|
23
|
+
#
|
24
|
+
# = Examples
|
25
|
+
#
|
26
|
+
# Example 1: Compute Duration from two Timestamps in pseudo code.
|
27
|
+
#
|
28
|
+
# Timestamp start = ...;
|
29
|
+
# Timestamp end = ...;
|
30
|
+
# Duration duration = ...;
|
31
|
+
#
|
32
|
+
# duration.seconds = end.seconds - start.seconds;
|
33
|
+
# duration.nanos = end.nanos - start.nanos;
|
34
|
+
#
|
35
|
+
# if (duration.seconds < 0 && duration.nanos > 0) {
|
36
|
+
# duration.seconds += 1;
|
37
|
+
# duration.nanos -= 1000000000;
|
38
|
+
# } else if (durations.seconds > 0 && duration.nanos < 0) {
|
39
|
+
# duration.seconds -= 1;
|
40
|
+
# duration.nanos += 1000000000;
|
41
|
+
# }
|
42
|
+
#
|
43
|
+
# Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
44
|
+
#
|
45
|
+
# Timestamp start = ...;
|
46
|
+
# Duration duration = ...;
|
47
|
+
# Timestamp end = ...;
|
48
|
+
#
|
49
|
+
# end.seconds = start.seconds + duration.seconds;
|
50
|
+
# end.nanos = start.nanos + duration.nanos;
|
51
|
+
#
|
52
|
+
# if (end.nanos < 0) {
|
53
|
+
# end.seconds -= 1;
|
54
|
+
# end.nanos += 1000000000;
|
55
|
+
# } else if (end.nanos >= 1000000000) {
|
56
|
+
# end.seconds += 1;
|
57
|
+
# end.nanos -= 1000000000;
|
58
|
+
# }
|
59
|
+
#
|
60
|
+
# Example 3: Compute Duration from datetime.timedelta in Python.
|
61
|
+
#
|
62
|
+
# td = datetime.timedelta(days=3, minutes=10)
|
63
|
+
# duration = Duration()
|
64
|
+
# duration.FromTimedelta(td)
|
65
|
+
#
|
66
|
+
# = JSON Mapping
|
67
|
+
#
|
68
|
+
# In JSON format, the Duration type is encoded as a string rather than an
|
69
|
+
# object, where the string ends in the suffix "s" (indicating seconds) and
|
70
|
+
# is preceded by the number of seconds, with nanoseconds expressed as
|
71
|
+
# fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
72
|
+
# encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
73
|
+
# be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
74
|
+
# microsecond should be expressed in JSON format as "3.000001s".
|
75
|
+
# @!attribute [rw] seconds
|
76
|
+
# @return [Integer]
|
77
|
+
# Signed seconds of the span of time. Must be from -315,576,000,000
|
78
|
+
# to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
79
|
+
# 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
80
|
+
# @!attribute [rw] nanos
|
81
|
+
# @return [Integer]
|
82
|
+
# Signed fractions of a second at nanosecond resolution of the span
|
83
|
+
# of time. Durations less than one second are represented with a 0
|
84
|
+
# +seconds+ field and a positive or negative +nanos+ field. For durations
|
85
|
+
# of one second or more, a non-zero value for the +nanos+ field must be
|
86
|
+
# of the same sign as the +seconds+ field. Must be from -999,999,999
|
87
|
+
# to +999,999,999 inclusive.
|
88
|
+
class Duration; end
|
89
|
+
end
|
90
|
+
end
|