google-cloud-tasks 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/google/cloud/tasks.rb +2 -2
- data/lib/google/cloud/tasks/v2beta3.rb +138 -0
- data/lib/google/cloud/tasks/v2beta3/cloud_tasks_client.rb +1254 -0
- data/lib/google/cloud/tasks/v2beta3/cloud_tasks_client_config.json +106 -0
- data/lib/google/cloud/tasks/v2beta3/cloudtasks_pb.rb +99 -0
- data/lib/google/cloud/tasks/v2beta3/cloudtasks_services_pb.rb +200 -0
- data/lib/google/cloud/tasks/v2beta3/credentials.rb +41 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/cloud/tasks/v2beta3/cloudtasks.rb +340 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/cloud/tasks/v2beta3/queue.rb +306 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/cloud/tasks/v2beta3/target.rb +265 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/cloud/tasks/v2beta3/task.rb +141 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/iam/v1/iam_policy.rb +63 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/iam/v1/policy.rb +128 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/any.rb +130 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/duration.rb +91 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/field_mask.rb +230 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/timestamp.rb +109 -0
- data/lib/google/cloud/tasks/v2beta3/doc/google/rpc/status.rb +84 -0
- data/lib/google/cloud/tasks/v2beta3/queue_pb.rb +53 -0
- data/lib/google/cloud/tasks/v2beta3/target_pb.rb +46 -0
- data/lib/google/cloud/tasks/v2beta3/task_pb.rb +48 -0
- metadata +25 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d9efb4b67b543ef70fe0641801f66c5ff555c06c5f4f75ea8fb949b79cb448a
|
4
|
+
data.tar.gz: 257aa1f57a87a86ef572abd635c524ea915ddef2d7cb25736005e69f953dd10d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4804f6eea63b8babcba7d33cd327411c1b9927afae0fed36e857b15e926649b5b1c74bc6a7ce99ea3c4bf623abc548b9193a9e2f95c794c63f4ff35c3f6b16ad
|
7
|
+
data.tar.gz: abac8ada723555304fd1ec75d223a423709a68eab719f138aaff8210354057953e1afe4cd92c71746faa7fa75b6567dcfba95bb2ecaa566129a70177950248c4
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ $ gem install google-cloud-tasks
|
|
27
27
|
- View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
28
28
|
to see the full list of Cloud APIs that we cover.
|
29
29
|
|
30
|
-
[Client Library Documentation]: https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-tasks/latest/google/cloud/tasks/
|
30
|
+
[Client Library Documentation]: https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-tasks/latest/google/cloud/tasks/v2beta3
|
31
31
|
[Product Documentation]: https://cloud.google.com/tasks
|
32
32
|
|
33
33
|
## Enabling Logging
|
data/lib/google/cloud/tasks.rb
CHANGED
@@ -91,7 +91,7 @@ module Google
|
|
91
91
|
# work in their applications.
|
92
92
|
#
|
93
93
|
# @param version [Symbol, String]
|
94
|
-
# The major version of the service to be used. By default :
|
94
|
+
# The major version of the service to be used. By default :v2beta3
|
95
95
|
# is used.
|
96
96
|
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
97
97
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
@@ -123,7 +123,7 @@ module Google
|
|
123
123
|
# @param exception_transformer [Proc]
|
124
124
|
# An optional proc that intercepts any exceptions raised during an API call to inject
|
125
125
|
# custom error handling.
|
126
|
-
def self.new(*args, version: :
|
126
|
+
def self.new(*args, version: :v2beta3, **kwargs)
|
127
127
|
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
128
128
|
raise "The version: #{version} is not available. The available versions " \
|
129
129
|
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
@@ -0,0 +1,138 @@
|
|
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
|
+
require "google/cloud/tasks/v2beta3/cloud_tasks_client"
|
17
|
+
|
18
|
+
module Google
|
19
|
+
module Cloud
|
20
|
+
module Tasks
|
21
|
+
# rubocop:disable LineLength
|
22
|
+
|
23
|
+
##
|
24
|
+
# # Ruby Client for Cloud Tasks API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
25
|
+
#
|
26
|
+
# [Cloud Tasks API][Product Documentation]:
|
27
|
+
# Manages the execution of large numbers of distributed requests.
|
28
|
+
# - [Product Documentation][]
|
29
|
+
#
|
30
|
+
# ## Quick Start
|
31
|
+
# In order to use this library, you first need to go through the following
|
32
|
+
# steps:
|
33
|
+
#
|
34
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
35
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
36
|
+
# 3. [Enable the Cloud Tasks API.](https://console.cloud.google.com/apis/library/tasks.googleapis.com)
|
37
|
+
# 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
38
|
+
#
|
39
|
+
# ### Installation
|
40
|
+
# ```
|
41
|
+
# $ gem install google-cloud-tasks
|
42
|
+
# ```
|
43
|
+
#
|
44
|
+
# ### Next Steps
|
45
|
+
# - Read the [Cloud Tasks API Product documentation][Product Documentation]
|
46
|
+
# to learn more about the product and see How-to Guides.
|
47
|
+
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
48
|
+
# to see the full list of Cloud APIs that we cover.
|
49
|
+
#
|
50
|
+
# [Product Documentation]: https://cloud.google.com/tasks
|
51
|
+
#
|
52
|
+
# ## Enabling Logging
|
53
|
+
#
|
54
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
55
|
+
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
56
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
57
|
+
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
58
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
59
|
+
#
|
60
|
+
# Configuring a Ruby stdlib logger:
|
61
|
+
#
|
62
|
+
# ```ruby
|
63
|
+
# require "logger"
|
64
|
+
#
|
65
|
+
# module MyLogger
|
66
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
67
|
+
# def logger
|
68
|
+
# LOGGER
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
73
|
+
# module GRPC
|
74
|
+
# extend MyLogger
|
75
|
+
# end
|
76
|
+
# ```
|
77
|
+
#
|
78
|
+
module V2beta3
|
79
|
+
# rubocop:enable LineLength
|
80
|
+
|
81
|
+
##
|
82
|
+
# Cloud Tasks allows developers to manage the execution of background
|
83
|
+
# work in their applications.
|
84
|
+
#
|
85
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
86
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
87
|
+
# be many types.
|
88
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
89
|
+
# authenticating requests made by this client.
|
90
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
91
|
+
# credentials for this client.
|
92
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
93
|
+
# credentials for this client.
|
94
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
95
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
96
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
97
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
98
|
+
# metadata for requests, generally, to give OAuth credentials.
|
99
|
+
# @param scopes [Array<String>]
|
100
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
101
|
+
# an updater_proc is supplied.
|
102
|
+
# @param client_config [Hash]
|
103
|
+
# A Hash for call options for each method. See
|
104
|
+
# Google::Gax#construct_settings for the structure of
|
105
|
+
# this data. Falls back to the default config if not specified
|
106
|
+
# or the specified config is missing data points.
|
107
|
+
# @param timeout [Numeric]
|
108
|
+
# The default timeout, in seconds, for calls made through this client.
|
109
|
+
# @param metadata [Hash]
|
110
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
111
|
+
# @param exception_transformer [Proc]
|
112
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
113
|
+
# custom error handling.
|
114
|
+
def self.new \
|
115
|
+
credentials: nil,
|
116
|
+
scopes: nil,
|
117
|
+
client_config: nil,
|
118
|
+
timeout: nil,
|
119
|
+
metadata: nil,
|
120
|
+
exception_transformer: nil,
|
121
|
+
lib_name: nil,
|
122
|
+
lib_version: nil
|
123
|
+
kwargs = {
|
124
|
+
credentials: credentials,
|
125
|
+
scopes: scopes,
|
126
|
+
client_config: client_config,
|
127
|
+
timeout: timeout,
|
128
|
+
metadata: metadata,
|
129
|
+
exception_transformer: exception_transformer,
|
130
|
+
lib_name: lib_name,
|
131
|
+
lib_version: lib_version
|
132
|
+
}.select { |_, v| v != nil }
|
133
|
+
Google::Cloud::Tasks::V2beta3::CloudTasksClient.new(**kwargs)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,1254 @@
|
|
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
|
+
# EDITING INSTRUCTIONS
|
16
|
+
# This file was generated from the file
|
17
|
+
# https://github.com/googleapis/googleapis/blob/master/google/cloud/tasks/v2beta3/cloudtasks.proto,
|
18
|
+
# and updates to that file get reflected here through a refresh process.
|
19
|
+
# For the short term, the refresh process will only be runnable by Google
|
20
|
+
# engineers.
|
21
|
+
|
22
|
+
|
23
|
+
require "json"
|
24
|
+
require "pathname"
|
25
|
+
|
26
|
+
require "google/gax"
|
27
|
+
|
28
|
+
require "google/cloud/tasks/v2beta3/cloudtasks_pb"
|
29
|
+
require "google/cloud/tasks/v2beta3/credentials"
|
30
|
+
|
31
|
+
module Google
|
32
|
+
module Cloud
|
33
|
+
module Tasks
|
34
|
+
module V2beta3
|
35
|
+
# Cloud Tasks allows developers to manage the execution of background
|
36
|
+
# work in their applications.
|
37
|
+
#
|
38
|
+
# @!attribute [r] cloud_tasks_stub
|
39
|
+
# @return [Google::Cloud::Tasks::V2beta3::CloudTasks::Stub]
|
40
|
+
class CloudTasksClient
|
41
|
+
# @private
|
42
|
+
attr_reader :cloud_tasks_stub
|
43
|
+
|
44
|
+
# The default address of the service.
|
45
|
+
SERVICE_ADDRESS = "cloudtasks.googleapis.com".freeze
|
46
|
+
|
47
|
+
# The default port of the service.
|
48
|
+
DEFAULT_SERVICE_PORT = 443
|
49
|
+
|
50
|
+
# The default set of gRPC interceptors.
|
51
|
+
GRPC_INTERCEPTORS = []
|
52
|
+
|
53
|
+
DEFAULT_TIMEOUT = 30
|
54
|
+
|
55
|
+
PAGE_DESCRIPTORS = {
|
56
|
+
"list_queues" => Google::Gax::PageDescriptor.new(
|
57
|
+
"page_token",
|
58
|
+
"next_page_token",
|
59
|
+
"queues"),
|
60
|
+
"list_tasks" => Google::Gax::PageDescriptor.new(
|
61
|
+
"page_token",
|
62
|
+
"next_page_token",
|
63
|
+
"tasks")
|
64
|
+
}.freeze
|
65
|
+
|
66
|
+
private_constant :PAGE_DESCRIPTORS
|
67
|
+
|
68
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
69
|
+
# this service.
|
70
|
+
ALL_SCOPES = [
|
71
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
72
|
+
].freeze
|
73
|
+
|
74
|
+
|
75
|
+
PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
76
|
+
"projects/{project}"
|
77
|
+
)
|
78
|
+
|
79
|
+
private_constant :PROJECT_PATH_TEMPLATE
|
80
|
+
|
81
|
+
LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
82
|
+
"projects/{project}/locations/{location}"
|
83
|
+
)
|
84
|
+
|
85
|
+
private_constant :LOCATION_PATH_TEMPLATE
|
86
|
+
|
87
|
+
QUEUE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
88
|
+
"projects/{project}/locations/{location}/queues/{queue}"
|
89
|
+
)
|
90
|
+
|
91
|
+
private_constant :QUEUE_PATH_TEMPLATE
|
92
|
+
|
93
|
+
TASK_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
94
|
+
"projects/{project}/locations/{location}/queues/{queue}/tasks/{task}"
|
95
|
+
)
|
96
|
+
|
97
|
+
private_constant :TASK_PATH_TEMPLATE
|
98
|
+
|
99
|
+
# Returns a fully-qualified project resource name string.
|
100
|
+
# @param project [String]
|
101
|
+
# @return [String]
|
102
|
+
def self.project_path project
|
103
|
+
PROJECT_PATH_TEMPLATE.render(
|
104
|
+
:"project" => project
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Returns a fully-qualified location resource name string.
|
109
|
+
# @param project [String]
|
110
|
+
# @param location [String]
|
111
|
+
# @return [String]
|
112
|
+
def self.location_path project, location
|
113
|
+
LOCATION_PATH_TEMPLATE.render(
|
114
|
+
:"project" => project,
|
115
|
+
:"location" => location
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Returns a fully-qualified queue resource name string.
|
120
|
+
# @param project [String]
|
121
|
+
# @param location [String]
|
122
|
+
# @param queue [String]
|
123
|
+
# @return [String]
|
124
|
+
def self.queue_path project, location, queue
|
125
|
+
QUEUE_PATH_TEMPLATE.render(
|
126
|
+
:"project" => project,
|
127
|
+
:"location" => location,
|
128
|
+
:"queue" => queue
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns a fully-qualified task resource name string.
|
133
|
+
# @param project [String]
|
134
|
+
# @param location [String]
|
135
|
+
# @param queue [String]
|
136
|
+
# @param task [String]
|
137
|
+
# @return [String]
|
138
|
+
def self.task_path project, location, queue, task
|
139
|
+
TASK_PATH_TEMPLATE.render(
|
140
|
+
:"project" => project,
|
141
|
+
:"location" => location,
|
142
|
+
:"queue" => queue,
|
143
|
+
:"task" => task
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
148
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
149
|
+
# be many types.
|
150
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
151
|
+
# authenticating requests made by this client.
|
152
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
153
|
+
# credentials for this client.
|
154
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
155
|
+
# credentials for this client.
|
156
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
157
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
158
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
159
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
160
|
+
# metadata for requests, generally, to give OAuth credentials.
|
161
|
+
# @param scopes [Array<String>]
|
162
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
163
|
+
# an updater_proc is supplied.
|
164
|
+
# @param client_config [Hash]
|
165
|
+
# A Hash for call options for each method. See
|
166
|
+
# Google::Gax#construct_settings for the structure of
|
167
|
+
# this data. Falls back to the default config if not specified
|
168
|
+
# or the specified config is missing data points.
|
169
|
+
# @param timeout [Numeric]
|
170
|
+
# The default timeout, in seconds, for calls made through this client.
|
171
|
+
# @param metadata [Hash]
|
172
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
173
|
+
# @param exception_transformer [Proc]
|
174
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
175
|
+
# custom error handling.
|
176
|
+
def initialize \
|
177
|
+
credentials: nil,
|
178
|
+
scopes: ALL_SCOPES,
|
179
|
+
client_config: {},
|
180
|
+
timeout: DEFAULT_TIMEOUT,
|
181
|
+
metadata: nil,
|
182
|
+
exception_transformer: nil,
|
183
|
+
lib_name: nil,
|
184
|
+
lib_version: ""
|
185
|
+
# These require statements are intentionally placed here to initialize
|
186
|
+
# the gRPC module only when it's required.
|
187
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
188
|
+
require "google/gax/grpc"
|
189
|
+
require "google/cloud/tasks/v2beta3/cloudtasks_services_pb"
|
190
|
+
|
191
|
+
credentials ||= Google::Cloud::Tasks::V2beta3::Credentials.default
|
192
|
+
|
193
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
194
|
+
updater_proc = Google::Cloud::Tasks::V2beta3::Credentials.new(credentials).updater_proc
|
195
|
+
end
|
196
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
197
|
+
channel = credentials
|
198
|
+
end
|
199
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
200
|
+
chan_creds = credentials
|
201
|
+
end
|
202
|
+
if credentials.is_a?(Proc)
|
203
|
+
updater_proc = credentials
|
204
|
+
end
|
205
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
206
|
+
updater_proc = credentials.updater_proc
|
207
|
+
end
|
208
|
+
|
209
|
+
package_version = Gem.loaded_specs['google-cloud-tasks'].version.version
|
210
|
+
|
211
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
212
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
213
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
214
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
215
|
+
google_api_client.freeze
|
216
|
+
|
217
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
218
|
+
headers.merge!(metadata) unless metadata.nil?
|
219
|
+
client_config_file = Pathname.new(__dir__).join(
|
220
|
+
"cloud_tasks_client_config.json"
|
221
|
+
)
|
222
|
+
defaults = client_config_file.open do |f|
|
223
|
+
Google::Gax.construct_settings(
|
224
|
+
"google.cloud.tasks.v2beta3.CloudTasks",
|
225
|
+
JSON.parse(f.read),
|
226
|
+
client_config,
|
227
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
228
|
+
timeout,
|
229
|
+
page_descriptors: PAGE_DESCRIPTORS,
|
230
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
231
|
+
metadata: headers
|
232
|
+
)
|
233
|
+
end
|
234
|
+
|
235
|
+
# Allow overriding the service path/port in subclasses.
|
236
|
+
service_path = self.class::SERVICE_ADDRESS
|
237
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
238
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
239
|
+
@cloud_tasks_stub = Google::Gax::Grpc.create_stub(
|
240
|
+
service_path,
|
241
|
+
port,
|
242
|
+
chan_creds: chan_creds,
|
243
|
+
channel: channel,
|
244
|
+
updater_proc: updater_proc,
|
245
|
+
scopes: scopes,
|
246
|
+
interceptors: interceptors,
|
247
|
+
&Google::Cloud::Tasks::V2beta3::CloudTasks::Stub.method(:new)
|
248
|
+
)
|
249
|
+
|
250
|
+
@list_queues = Google::Gax.create_api_call(
|
251
|
+
@cloud_tasks_stub.method(:list_queues),
|
252
|
+
defaults["list_queues"],
|
253
|
+
exception_transformer: exception_transformer,
|
254
|
+
params_extractor: proc do |request|
|
255
|
+
{'parent' => request.parent}
|
256
|
+
end
|
257
|
+
)
|
258
|
+
@get_queue = Google::Gax.create_api_call(
|
259
|
+
@cloud_tasks_stub.method(:get_queue),
|
260
|
+
defaults["get_queue"],
|
261
|
+
exception_transformer: exception_transformer,
|
262
|
+
params_extractor: proc do |request|
|
263
|
+
{'name' => request.name}
|
264
|
+
end
|
265
|
+
)
|
266
|
+
@create_queue = Google::Gax.create_api_call(
|
267
|
+
@cloud_tasks_stub.method(:create_queue),
|
268
|
+
defaults["create_queue"],
|
269
|
+
exception_transformer: exception_transformer,
|
270
|
+
params_extractor: proc do |request|
|
271
|
+
{'parent' => request.parent}
|
272
|
+
end
|
273
|
+
)
|
274
|
+
@update_queue = Google::Gax.create_api_call(
|
275
|
+
@cloud_tasks_stub.method(:update_queue),
|
276
|
+
defaults["update_queue"],
|
277
|
+
exception_transformer: exception_transformer,
|
278
|
+
params_extractor: proc do |request|
|
279
|
+
{'queue.name' => request.queue.name}
|
280
|
+
end
|
281
|
+
)
|
282
|
+
@delete_queue = Google::Gax.create_api_call(
|
283
|
+
@cloud_tasks_stub.method(:delete_queue),
|
284
|
+
defaults["delete_queue"],
|
285
|
+
exception_transformer: exception_transformer,
|
286
|
+
params_extractor: proc do |request|
|
287
|
+
{'name' => request.name}
|
288
|
+
end
|
289
|
+
)
|
290
|
+
@purge_queue = Google::Gax.create_api_call(
|
291
|
+
@cloud_tasks_stub.method(:purge_queue),
|
292
|
+
defaults["purge_queue"],
|
293
|
+
exception_transformer: exception_transformer,
|
294
|
+
params_extractor: proc do |request|
|
295
|
+
{'name' => request.name}
|
296
|
+
end
|
297
|
+
)
|
298
|
+
@pause_queue = Google::Gax.create_api_call(
|
299
|
+
@cloud_tasks_stub.method(:pause_queue),
|
300
|
+
defaults["pause_queue"],
|
301
|
+
exception_transformer: exception_transformer,
|
302
|
+
params_extractor: proc do |request|
|
303
|
+
{'name' => request.name}
|
304
|
+
end
|
305
|
+
)
|
306
|
+
@resume_queue = Google::Gax.create_api_call(
|
307
|
+
@cloud_tasks_stub.method(:resume_queue),
|
308
|
+
defaults["resume_queue"],
|
309
|
+
exception_transformer: exception_transformer,
|
310
|
+
params_extractor: proc do |request|
|
311
|
+
{'name' => request.name}
|
312
|
+
end
|
313
|
+
)
|
314
|
+
@get_iam_policy = Google::Gax.create_api_call(
|
315
|
+
@cloud_tasks_stub.method(:get_iam_policy),
|
316
|
+
defaults["get_iam_policy"],
|
317
|
+
exception_transformer: exception_transformer,
|
318
|
+
params_extractor: proc do |request|
|
319
|
+
{'resource' => request.resource}
|
320
|
+
end
|
321
|
+
)
|
322
|
+
@set_iam_policy = Google::Gax.create_api_call(
|
323
|
+
@cloud_tasks_stub.method(:set_iam_policy),
|
324
|
+
defaults["set_iam_policy"],
|
325
|
+
exception_transformer: exception_transformer,
|
326
|
+
params_extractor: proc do |request|
|
327
|
+
{'resource' => request.resource}
|
328
|
+
end
|
329
|
+
)
|
330
|
+
@test_iam_permissions = Google::Gax.create_api_call(
|
331
|
+
@cloud_tasks_stub.method(:test_iam_permissions),
|
332
|
+
defaults["test_iam_permissions"],
|
333
|
+
exception_transformer: exception_transformer,
|
334
|
+
params_extractor: proc do |request|
|
335
|
+
{'resource' => request.resource}
|
336
|
+
end
|
337
|
+
)
|
338
|
+
@list_tasks = Google::Gax.create_api_call(
|
339
|
+
@cloud_tasks_stub.method(:list_tasks),
|
340
|
+
defaults["list_tasks"],
|
341
|
+
exception_transformer: exception_transformer,
|
342
|
+
params_extractor: proc do |request|
|
343
|
+
{'parent' => request.parent}
|
344
|
+
end
|
345
|
+
)
|
346
|
+
@get_task = Google::Gax.create_api_call(
|
347
|
+
@cloud_tasks_stub.method(:get_task),
|
348
|
+
defaults["get_task"],
|
349
|
+
exception_transformer: exception_transformer,
|
350
|
+
params_extractor: proc do |request|
|
351
|
+
{'name' => request.name}
|
352
|
+
end
|
353
|
+
)
|
354
|
+
@create_task = Google::Gax.create_api_call(
|
355
|
+
@cloud_tasks_stub.method(:create_task),
|
356
|
+
defaults["create_task"],
|
357
|
+
exception_transformer: exception_transformer,
|
358
|
+
params_extractor: proc do |request|
|
359
|
+
{'parent' => request.parent}
|
360
|
+
end
|
361
|
+
)
|
362
|
+
@delete_task = Google::Gax.create_api_call(
|
363
|
+
@cloud_tasks_stub.method(:delete_task),
|
364
|
+
defaults["delete_task"],
|
365
|
+
exception_transformer: exception_transformer,
|
366
|
+
params_extractor: proc do |request|
|
367
|
+
{'name' => request.name}
|
368
|
+
end
|
369
|
+
)
|
370
|
+
@run_task = Google::Gax.create_api_call(
|
371
|
+
@cloud_tasks_stub.method(:run_task),
|
372
|
+
defaults["run_task"],
|
373
|
+
exception_transformer: exception_transformer,
|
374
|
+
params_extractor: proc do |request|
|
375
|
+
{'name' => request.name}
|
376
|
+
end
|
377
|
+
)
|
378
|
+
end
|
379
|
+
|
380
|
+
# Service calls
|
381
|
+
|
382
|
+
# Lists queues.
|
383
|
+
#
|
384
|
+
# Queues are returned in lexicographical order.
|
385
|
+
#
|
386
|
+
# @param parent [String]
|
387
|
+
# Required.
|
388
|
+
#
|
389
|
+
# The location name.
|
390
|
+
# For example: `projects/PROJECT_ID/locations/LOCATION_ID`
|
391
|
+
# @param filter [String]
|
392
|
+
# `filter` can be used to specify a subset of queues. Any {Google::Cloud::Tasks::V2beta3::Queue Queue}
|
393
|
+
# field can be used as a filter and several operators as supported.
|
394
|
+
# For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as
|
395
|
+
# described in
|
396
|
+
# [Stackdriver's Advanced Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
|
397
|
+
#
|
398
|
+
# Sample filter "state: PAUSED".
|
399
|
+
#
|
400
|
+
# Note that using filters might cause fewer queues than the
|
401
|
+
# requested page_size to be returned.
|
402
|
+
# @param page_size [Integer]
|
403
|
+
# The maximum number of resources contained in the underlying API
|
404
|
+
# response. If page streaming is performed per-resource, this
|
405
|
+
# parameter does not affect the return value. If page streaming is
|
406
|
+
# performed per-page, this determines the maximum number of
|
407
|
+
# resources in a page.
|
408
|
+
# @param options [Google::Gax::CallOptions]
|
409
|
+
# Overrides the default settings for this call, e.g, timeout,
|
410
|
+
# retries, etc.
|
411
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
412
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta3::Queue>]
|
413
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
414
|
+
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta3::Queue>]
|
415
|
+
# An enumerable of Google::Cloud::Tasks::V2beta3::Queue instances.
|
416
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
417
|
+
# operations such as per-page iteration or access to the response
|
418
|
+
# object.
|
419
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
420
|
+
# @example
|
421
|
+
# require "google/cloud/tasks"
|
422
|
+
#
|
423
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
424
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
|
425
|
+
#
|
426
|
+
# # Iterate over all results.
|
427
|
+
# cloud_tasks_client.list_queues(formatted_parent).each do |element|
|
428
|
+
# # Process element.
|
429
|
+
# end
|
430
|
+
#
|
431
|
+
# # Or iterate over results one page at a time.
|
432
|
+
# cloud_tasks_client.list_queues(formatted_parent).each_page do |page|
|
433
|
+
# # Process each page at a time.
|
434
|
+
# page.each do |element|
|
435
|
+
# # Process element.
|
436
|
+
# end
|
437
|
+
# end
|
438
|
+
|
439
|
+
def list_queues \
|
440
|
+
parent,
|
441
|
+
filter: nil,
|
442
|
+
page_size: nil,
|
443
|
+
options: nil,
|
444
|
+
&block
|
445
|
+
req = {
|
446
|
+
parent: parent,
|
447
|
+
filter: filter,
|
448
|
+
page_size: page_size
|
449
|
+
}.delete_if { |_, v| v.nil? }
|
450
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::ListQueuesRequest)
|
451
|
+
@list_queues.call(req, options, &block)
|
452
|
+
end
|
453
|
+
|
454
|
+
# Gets a queue.
|
455
|
+
#
|
456
|
+
# @param name [String]
|
457
|
+
# Required.
|
458
|
+
#
|
459
|
+
# The resource name of the queue. For example:
|
460
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
|
461
|
+
# @param options [Google::Gax::CallOptions]
|
462
|
+
# Overrides the default settings for this call, e.g, timeout,
|
463
|
+
# retries, etc.
|
464
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
465
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
|
466
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
467
|
+
# @return [Google::Cloud::Tasks::V2beta3::Queue]
|
468
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
469
|
+
# @example
|
470
|
+
# require "google/cloud/tasks"
|
471
|
+
#
|
472
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
473
|
+
# formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
474
|
+
# response = cloud_tasks_client.get_queue(formatted_name)
|
475
|
+
|
476
|
+
def get_queue \
|
477
|
+
name,
|
478
|
+
options: nil,
|
479
|
+
&block
|
480
|
+
req = {
|
481
|
+
name: name
|
482
|
+
}.delete_if { |_, v| v.nil? }
|
483
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::GetQueueRequest)
|
484
|
+
@get_queue.call(req, options, &block)
|
485
|
+
end
|
486
|
+
|
487
|
+
# Creates a queue.
|
488
|
+
#
|
489
|
+
# Queues created with this method allow tasks to live for a maximum of 31
|
490
|
+
# days. After a task is 31 days old, the task will be deleted regardless of whether
|
491
|
+
# it was dispatched or not.
|
492
|
+
#
|
493
|
+
# WARNING: Using this method may have unintended side effects if you are
|
494
|
+
# using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
|
495
|
+
# Read
|
496
|
+
# [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml)
|
497
|
+
# before using this method.
|
498
|
+
#
|
499
|
+
# @param parent [String]
|
500
|
+
# Required.
|
501
|
+
#
|
502
|
+
# The location name in which the queue will be created.
|
503
|
+
# For example: `projects/PROJECT_ID/locations/LOCATION_ID`
|
504
|
+
#
|
505
|
+
# The list of allowed locations can be obtained by calling Cloud
|
506
|
+
# Tasks' implementation of
|
507
|
+
# {Google::Cloud::Location::Locations::ListLocations ListLocations}.
|
508
|
+
# @param queue [Google::Cloud::Tasks::V2beta3::Queue | Hash]
|
509
|
+
# Required.
|
510
|
+
#
|
511
|
+
# The queue to create.
|
512
|
+
#
|
513
|
+
# {Google::Cloud::Tasks::V2beta3::Queue#name Queue's name} cannot be the same as an existing queue.
|
514
|
+
# A hash of the same form as `Google::Cloud::Tasks::V2beta3::Queue`
|
515
|
+
# can also be provided.
|
516
|
+
# @param options [Google::Gax::CallOptions]
|
517
|
+
# Overrides the default settings for this call, e.g, timeout,
|
518
|
+
# retries, etc.
|
519
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
520
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
|
521
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
522
|
+
# @return [Google::Cloud::Tasks::V2beta3::Queue]
|
523
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
524
|
+
# @example
|
525
|
+
# require "google/cloud/tasks"
|
526
|
+
#
|
527
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
528
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
|
529
|
+
#
|
530
|
+
# # TODO: Initialize `queue`:
|
531
|
+
# queue = {}
|
532
|
+
# response = cloud_tasks_client.create_queue(formatted_parent, queue)
|
533
|
+
|
534
|
+
def create_queue \
|
535
|
+
parent,
|
536
|
+
queue,
|
537
|
+
options: nil,
|
538
|
+
&block
|
539
|
+
req = {
|
540
|
+
parent: parent,
|
541
|
+
queue: queue
|
542
|
+
}.delete_if { |_, v| v.nil? }
|
543
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::CreateQueueRequest)
|
544
|
+
@create_queue.call(req, options, &block)
|
545
|
+
end
|
546
|
+
|
547
|
+
# Updates a queue.
|
548
|
+
#
|
549
|
+
# This method creates the queue if it does not exist and updates
|
550
|
+
# the queue if it does exist.
|
551
|
+
#
|
552
|
+
# Queues created with this method allow tasks to live for a maximum of 31
|
553
|
+
# days. After a task is 31 days old, the task will be deleted regardless of whether
|
554
|
+
# it was dispatched or not.
|
555
|
+
#
|
556
|
+
# WARNING: Using this method may have unintended side effects if you are
|
557
|
+
# using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
|
558
|
+
# Read
|
559
|
+
# [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml)
|
560
|
+
# before using this method.
|
561
|
+
#
|
562
|
+
# @param queue [Google::Cloud::Tasks::V2beta3::Queue | Hash]
|
563
|
+
# Required.
|
564
|
+
#
|
565
|
+
# The queue to create or update.
|
566
|
+
#
|
567
|
+
# The queue's {Google::Cloud::Tasks::V2beta3::Queue#name name} must be specified.
|
568
|
+
#
|
569
|
+
# Output only fields cannot be modified using UpdateQueue.
|
570
|
+
# Any value specified for an output only field will be ignored.
|
571
|
+
# The queue's {Google::Cloud::Tasks::V2beta3::Queue#name name} cannot be changed.
|
572
|
+
# A hash of the same form as `Google::Cloud::Tasks::V2beta3::Queue`
|
573
|
+
# can also be provided.
|
574
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
575
|
+
# A mask used to specify which fields of the queue are being updated.
|
576
|
+
#
|
577
|
+
# If empty, then all fields will be updated.
|
578
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
579
|
+
# can also be provided.
|
580
|
+
# @param options [Google::Gax::CallOptions]
|
581
|
+
# Overrides the default settings for this call, e.g, timeout,
|
582
|
+
# retries, etc.
|
583
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
584
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
|
585
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
586
|
+
# @return [Google::Cloud::Tasks::V2beta3::Queue]
|
587
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
588
|
+
# @example
|
589
|
+
# require "google/cloud/tasks"
|
590
|
+
#
|
591
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
592
|
+
#
|
593
|
+
# # TODO: Initialize `queue`:
|
594
|
+
# queue = {}
|
595
|
+
# response = cloud_tasks_client.update_queue(queue)
|
596
|
+
|
597
|
+
def update_queue \
|
598
|
+
queue,
|
599
|
+
update_mask: nil,
|
600
|
+
options: nil,
|
601
|
+
&block
|
602
|
+
req = {
|
603
|
+
queue: queue,
|
604
|
+
update_mask: update_mask
|
605
|
+
}.delete_if { |_, v| v.nil? }
|
606
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::UpdateQueueRequest)
|
607
|
+
@update_queue.call(req, options, &block)
|
608
|
+
end
|
609
|
+
|
610
|
+
# Deletes a queue.
|
611
|
+
#
|
612
|
+
# This command will delete the queue even if it has tasks in it.
|
613
|
+
#
|
614
|
+
# Note: If you delete a queue, a queue with the same name can't be created
|
615
|
+
# for 7 days.
|
616
|
+
#
|
617
|
+
# WARNING: Using this method may have unintended side effects if you are
|
618
|
+
# using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
|
619
|
+
# Read
|
620
|
+
# [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml)
|
621
|
+
# before using this method.
|
622
|
+
#
|
623
|
+
# @param name [String]
|
624
|
+
# Required.
|
625
|
+
#
|
626
|
+
# The queue name. For example:
|
627
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
|
628
|
+
# @param options [Google::Gax::CallOptions]
|
629
|
+
# Overrides the default settings for this call, e.g, timeout,
|
630
|
+
# retries, etc.
|
631
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
632
|
+
# @yieldparam result []
|
633
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
634
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
635
|
+
# @example
|
636
|
+
# require "google/cloud/tasks"
|
637
|
+
#
|
638
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
639
|
+
# formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
640
|
+
# cloud_tasks_client.delete_queue(formatted_name)
|
641
|
+
|
642
|
+
def delete_queue \
|
643
|
+
name,
|
644
|
+
options: nil,
|
645
|
+
&block
|
646
|
+
req = {
|
647
|
+
name: name
|
648
|
+
}.delete_if { |_, v| v.nil? }
|
649
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::DeleteQueueRequest)
|
650
|
+
@delete_queue.call(req, options, &block)
|
651
|
+
nil
|
652
|
+
end
|
653
|
+
|
654
|
+
# Purges a queue by deleting all of its tasks.
|
655
|
+
#
|
656
|
+
# All tasks created before this method is called are permanently deleted.
|
657
|
+
#
|
658
|
+
# Purge operations can take up to one minute to take effect. Tasks
|
659
|
+
# might be dispatched before the purge takes effect. A purge is irreversible.
|
660
|
+
#
|
661
|
+
# @param name [String]
|
662
|
+
# Required.
|
663
|
+
#
|
664
|
+
# The queue name. For example:
|
665
|
+
# `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
|
666
|
+
# @param options [Google::Gax::CallOptions]
|
667
|
+
# Overrides the default settings for this call, e.g, timeout,
|
668
|
+
# retries, etc.
|
669
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
670
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
|
671
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
672
|
+
# @return [Google::Cloud::Tasks::V2beta3::Queue]
|
673
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
674
|
+
# @example
|
675
|
+
# require "google/cloud/tasks"
|
676
|
+
#
|
677
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
678
|
+
# formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
679
|
+
# response = cloud_tasks_client.purge_queue(formatted_name)
|
680
|
+
|
681
|
+
def purge_queue \
|
682
|
+
name,
|
683
|
+
options: nil,
|
684
|
+
&block
|
685
|
+
req = {
|
686
|
+
name: name
|
687
|
+
}.delete_if { |_, v| v.nil? }
|
688
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::PurgeQueueRequest)
|
689
|
+
@purge_queue.call(req, options, &block)
|
690
|
+
end
|
691
|
+
|
692
|
+
# Pauses the queue.
|
693
|
+
#
|
694
|
+
# If a queue is paused then the system will stop dispatching tasks
|
695
|
+
# until the queue is resumed via
|
696
|
+
# {Google::Cloud::Tasks::V2beta3::CloudTasks::ResumeQueue ResumeQueue}. Tasks can still be added
|
697
|
+
# when the queue is paused. A queue is paused if its
|
698
|
+
# {Google::Cloud::Tasks::V2beta3::Queue#state state} is {Google::Cloud::Tasks::V2beta3::Queue::State::PAUSED PAUSED}.
|
699
|
+
#
|
700
|
+
# @param name [String]
|
701
|
+
# Required.
|
702
|
+
#
|
703
|
+
# The queue name. For example:
|
704
|
+
# `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
|
705
|
+
# @param options [Google::Gax::CallOptions]
|
706
|
+
# Overrides the default settings for this call, e.g, timeout,
|
707
|
+
# retries, etc.
|
708
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
709
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
|
710
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
711
|
+
# @return [Google::Cloud::Tasks::V2beta3::Queue]
|
712
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
713
|
+
# @example
|
714
|
+
# require "google/cloud/tasks"
|
715
|
+
#
|
716
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
717
|
+
# formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
718
|
+
# response = cloud_tasks_client.pause_queue(formatted_name)
|
719
|
+
|
720
|
+
def pause_queue \
|
721
|
+
name,
|
722
|
+
options: nil,
|
723
|
+
&block
|
724
|
+
req = {
|
725
|
+
name: name
|
726
|
+
}.delete_if { |_, v| v.nil? }
|
727
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::PauseQueueRequest)
|
728
|
+
@pause_queue.call(req, options, &block)
|
729
|
+
end
|
730
|
+
|
731
|
+
# Resume a queue.
|
732
|
+
#
|
733
|
+
# This method resumes a queue after it has been
|
734
|
+
# {Google::Cloud::Tasks::V2beta3::Queue::State::PAUSED PAUSED} or
|
735
|
+
# {Google::Cloud::Tasks::V2beta3::Queue::State::DISABLED DISABLED}. The state of a queue is stored
|
736
|
+
# in the queue's {Google::Cloud::Tasks::V2beta3::Queue#state state}; after calling this method it
|
737
|
+
# will be set to {Google::Cloud::Tasks::V2beta3::Queue::State::RUNNING RUNNING}.
|
738
|
+
#
|
739
|
+
# WARNING: Resuming many high-QPS queues at the same time can
|
740
|
+
# lead to target overloading. If you are resuming high-QPS
|
741
|
+
# queues, follow the 500/50/5 pattern described in
|
742
|
+
# [Managing Cloud Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
|
743
|
+
#
|
744
|
+
# @param name [String]
|
745
|
+
# Required.
|
746
|
+
#
|
747
|
+
# The queue name. For example:
|
748
|
+
# `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
|
749
|
+
# @param options [Google::Gax::CallOptions]
|
750
|
+
# Overrides the default settings for this call, e.g, timeout,
|
751
|
+
# retries, etc.
|
752
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
753
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
|
754
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
755
|
+
# @return [Google::Cloud::Tasks::V2beta3::Queue]
|
756
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
757
|
+
# @example
|
758
|
+
# require "google/cloud/tasks"
|
759
|
+
#
|
760
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
761
|
+
# formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
762
|
+
# response = cloud_tasks_client.resume_queue(formatted_name)
|
763
|
+
|
764
|
+
def resume_queue \
|
765
|
+
name,
|
766
|
+
options: nil,
|
767
|
+
&block
|
768
|
+
req = {
|
769
|
+
name: name
|
770
|
+
}.delete_if { |_, v| v.nil? }
|
771
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::ResumeQueueRequest)
|
772
|
+
@resume_queue.call(req, options, &block)
|
773
|
+
end
|
774
|
+
|
775
|
+
# Gets the access control policy for a {Google::Cloud::Tasks::V2beta3::Queue Queue}.
|
776
|
+
# Returns an empty policy if the resource exists and does not have a policy
|
777
|
+
# set.
|
778
|
+
#
|
779
|
+
# Authorization requires the following
|
780
|
+
# [Google IAM](https://cloud.google.com/iam) permission on the specified
|
781
|
+
# resource parent:
|
782
|
+
#
|
783
|
+
# * `cloudtasks.queues.getIamPolicy`
|
784
|
+
#
|
785
|
+
# @param resource [String]
|
786
|
+
# REQUIRED: The resource for which the policy is being requested.
|
787
|
+
# `resource` is usually specified as a path. For example, a Project
|
788
|
+
# resource is specified as `projects/{project}`.
|
789
|
+
# @param options [Google::Gax::CallOptions]
|
790
|
+
# Overrides the default settings for this call, e.g, timeout,
|
791
|
+
# retries, etc.
|
792
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
793
|
+
# @yieldparam result [Google::Iam::V1::Policy]
|
794
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
795
|
+
# @return [Google::Iam::V1::Policy]
|
796
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
797
|
+
# @example
|
798
|
+
# require "google/cloud/tasks"
|
799
|
+
#
|
800
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
801
|
+
# formatted_resource = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
802
|
+
# response = cloud_tasks_client.get_iam_policy(formatted_resource)
|
803
|
+
|
804
|
+
def get_iam_policy \
|
805
|
+
resource,
|
806
|
+
options: nil,
|
807
|
+
&block
|
808
|
+
req = {
|
809
|
+
resource: resource
|
810
|
+
}.delete_if { |_, v| v.nil? }
|
811
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
|
812
|
+
@get_iam_policy.call(req, options, &block)
|
813
|
+
end
|
814
|
+
|
815
|
+
# Sets the access control policy for a {Google::Cloud::Tasks::V2beta3::Queue Queue}. Replaces any existing
|
816
|
+
# policy.
|
817
|
+
#
|
818
|
+
# Note: The Cloud Console does not check queue-level IAM permissions yet.
|
819
|
+
# Project-level permissions are required to use the Cloud Console.
|
820
|
+
#
|
821
|
+
# Authorization requires the following
|
822
|
+
# [Google IAM](https://cloud.google.com/iam) permission on the specified
|
823
|
+
# resource parent:
|
824
|
+
#
|
825
|
+
# * `cloudtasks.queues.setIamPolicy`
|
826
|
+
#
|
827
|
+
# @param resource [String]
|
828
|
+
# REQUIRED: The resource for which the policy is being specified.
|
829
|
+
# `resource` is usually specified as a path. For example, a Project
|
830
|
+
# resource is specified as `projects/{project}`.
|
831
|
+
# @param policy [Google::Iam::V1::Policy | Hash]
|
832
|
+
# REQUIRED: The complete policy to be applied to the `resource`. The size of
|
833
|
+
# the policy is limited to a few 10s of KB. An empty policy is a
|
834
|
+
# valid policy but certain Cloud Platform services (such as Projects)
|
835
|
+
# might reject them.
|
836
|
+
# A hash of the same form as `Google::Iam::V1::Policy`
|
837
|
+
# can also be provided.
|
838
|
+
# @param options [Google::Gax::CallOptions]
|
839
|
+
# Overrides the default settings for this call, e.g, timeout,
|
840
|
+
# retries, etc.
|
841
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
842
|
+
# @yieldparam result [Google::Iam::V1::Policy]
|
843
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
844
|
+
# @return [Google::Iam::V1::Policy]
|
845
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
846
|
+
# @example
|
847
|
+
# require "google/cloud/tasks"
|
848
|
+
#
|
849
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
850
|
+
# formatted_resource = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
851
|
+
#
|
852
|
+
# # TODO: Initialize `policy`:
|
853
|
+
# policy = {}
|
854
|
+
# response = cloud_tasks_client.set_iam_policy(formatted_resource, policy)
|
855
|
+
|
856
|
+
def set_iam_policy \
|
857
|
+
resource,
|
858
|
+
policy,
|
859
|
+
options: nil,
|
860
|
+
&block
|
861
|
+
req = {
|
862
|
+
resource: resource,
|
863
|
+
policy: policy
|
864
|
+
}.delete_if { |_, v| v.nil? }
|
865
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
|
866
|
+
@set_iam_policy.call(req, options, &block)
|
867
|
+
end
|
868
|
+
|
869
|
+
# Returns permissions that a caller has on a {Google::Cloud::Tasks::V2beta3::Queue Queue}.
|
870
|
+
# If the resource does not exist, this will return an empty set of
|
871
|
+
# permissions, not a {Google::Rpc::Code::NOT_FOUND NOT_FOUND} error.
|
872
|
+
#
|
873
|
+
# Note: This operation is designed to be used for building permission-aware
|
874
|
+
# UIs and command-line tools, not for authorization checking. This operation
|
875
|
+
# may "fail open" without warning.
|
876
|
+
#
|
877
|
+
# @param resource [String]
|
878
|
+
# REQUIRED: The resource for which the policy detail is being requested.
|
879
|
+
# `resource` is usually specified as a path. For example, a Project
|
880
|
+
# resource is specified as `projects/{project}`.
|
881
|
+
# @param permissions [Array<String>]
|
882
|
+
# The set of permissions to check for the `resource`. Permissions with
|
883
|
+
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
884
|
+
# information see
|
885
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
886
|
+
# @param options [Google::Gax::CallOptions]
|
887
|
+
# Overrides the default settings for this call, e.g, timeout,
|
888
|
+
# retries, etc.
|
889
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
890
|
+
# @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
|
891
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
892
|
+
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
893
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
894
|
+
# @example
|
895
|
+
# require "google/cloud/tasks"
|
896
|
+
#
|
897
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
898
|
+
# formatted_resource = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
899
|
+
#
|
900
|
+
# # TODO: Initialize `permissions`:
|
901
|
+
# permissions = []
|
902
|
+
# response = cloud_tasks_client.test_iam_permissions(formatted_resource, permissions)
|
903
|
+
|
904
|
+
def test_iam_permissions \
|
905
|
+
resource,
|
906
|
+
permissions,
|
907
|
+
options: nil,
|
908
|
+
&block
|
909
|
+
req = {
|
910
|
+
resource: resource,
|
911
|
+
permissions: permissions
|
912
|
+
}.delete_if { |_, v| v.nil? }
|
913
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
|
914
|
+
@test_iam_permissions.call(req, options, &block)
|
915
|
+
end
|
916
|
+
|
917
|
+
# Lists the tasks in a queue.
|
918
|
+
#
|
919
|
+
# By default, only the {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC} view is retrieved
|
920
|
+
# due to performance considerations;
|
921
|
+
# {Google::Cloud::Tasks::V2beta3::ListTasksRequest#response_view response_view} controls the
|
922
|
+
# subset of information which is returned.
|
923
|
+
#
|
924
|
+
# The tasks may be returned in any order. The ordering may change at any
|
925
|
+
# time.
|
926
|
+
#
|
927
|
+
# @param parent [String]
|
928
|
+
# Required.
|
929
|
+
#
|
930
|
+
# The queue name. For example:
|
931
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
|
932
|
+
# @param response_view [Google::Cloud::Tasks::V2beta3::Task::View]
|
933
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta3::Task Task} will be
|
934
|
+
# returned.
|
935
|
+
#
|
936
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC}; not all
|
937
|
+
# information is retrieved by default because some data, such as
|
938
|
+
# payloads, might be desirable to return only when needed because
|
939
|
+
# of its large size or because of the sensitivity of data that it
|
940
|
+
# contains.
|
941
|
+
#
|
942
|
+
# Authorization for {Google::Cloud::Tasks::V2beta3::Task::View::FULL FULL} requires
|
943
|
+
# `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
|
944
|
+
# permission on the {Google::Cloud::Tasks::V2beta3::Task Task} resource.
|
945
|
+
# @param page_size [Integer]
|
946
|
+
# The maximum number of resources contained in the underlying API
|
947
|
+
# response. If page streaming is performed per-resource, this
|
948
|
+
# parameter does not affect the return value. If page streaming is
|
949
|
+
# performed per-page, this determines the maximum number of
|
950
|
+
# resources in a page.
|
951
|
+
# @param options [Google::Gax::CallOptions]
|
952
|
+
# Overrides the default settings for this call, e.g, timeout,
|
953
|
+
# retries, etc.
|
954
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
955
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta3::Task>]
|
956
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
957
|
+
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta3::Task>]
|
958
|
+
# An enumerable of Google::Cloud::Tasks::V2beta3::Task instances.
|
959
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
960
|
+
# operations such as per-page iteration or access to the response
|
961
|
+
# object.
|
962
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
963
|
+
# @example
|
964
|
+
# require "google/cloud/tasks"
|
965
|
+
#
|
966
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
967
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
968
|
+
#
|
969
|
+
# # Iterate over all results.
|
970
|
+
# cloud_tasks_client.list_tasks(formatted_parent).each do |element|
|
971
|
+
# # Process element.
|
972
|
+
# end
|
973
|
+
#
|
974
|
+
# # Or iterate over results one page at a time.
|
975
|
+
# cloud_tasks_client.list_tasks(formatted_parent).each_page do |page|
|
976
|
+
# # Process each page at a time.
|
977
|
+
# page.each do |element|
|
978
|
+
# # Process element.
|
979
|
+
# end
|
980
|
+
# end
|
981
|
+
|
982
|
+
def list_tasks \
|
983
|
+
parent,
|
984
|
+
response_view: nil,
|
985
|
+
page_size: nil,
|
986
|
+
options: nil,
|
987
|
+
&block
|
988
|
+
req = {
|
989
|
+
parent: parent,
|
990
|
+
response_view: response_view,
|
991
|
+
page_size: page_size
|
992
|
+
}.delete_if { |_, v| v.nil? }
|
993
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::ListTasksRequest)
|
994
|
+
@list_tasks.call(req, options, &block)
|
995
|
+
end
|
996
|
+
|
997
|
+
# Gets a task.
|
998
|
+
#
|
999
|
+
# @param name [String]
|
1000
|
+
# Required.
|
1001
|
+
#
|
1002
|
+
# The task name. For example:
|
1003
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
|
1004
|
+
# @param response_view [Google::Cloud::Tasks::V2beta3::Task::View]
|
1005
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta3::Task Task} will be
|
1006
|
+
# returned.
|
1007
|
+
#
|
1008
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC}; not all
|
1009
|
+
# information is retrieved by default because some data, such as
|
1010
|
+
# payloads, might be desirable to return only when needed because
|
1011
|
+
# of its large size or because of the sensitivity of data that it
|
1012
|
+
# contains.
|
1013
|
+
#
|
1014
|
+
# Authorization for {Google::Cloud::Tasks::V2beta3::Task::View::FULL FULL} requires
|
1015
|
+
# `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
|
1016
|
+
# permission on the {Google::Cloud::Tasks::V2beta3::Task Task} resource.
|
1017
|
+
# @param options [Google::Gax::CallOptions]
|
1018
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1019
|
+
# retries, etc.
|
1020
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1021
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Task]
|
1022
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1023
|
+
# @return [Google::Cloud::Tasks::V2beta3::Task]
|
1024
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1025
|
+
# @example
|
1026
|
+
# require "google/cloud/tasks"
|
1027
|
+
#
|
1028
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
1029
|
+
# formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
1030
|
+
# response = cloud_tasks_client.get_task(formatted_name)
|
1031
|
+
|
1032
|
+
def get_task \
|
1033
|
+
name,
|
1034
|
+
response_view: nil,
|
1035
|
+
options: nil,
|
1036
|
+
&block
|
1037
|
+
req = {
|
1038
|
+
name: name,
|
1039
|
+
response_view: response_view
|
1040
|
+
}.delete_if { |_, v| v.nil? }
|
1041
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::GetTaskRequest)
|
1042
|
+
@get_task.call(req, options, &block)
|
1043
|
+
end
|
1044
|
+
|
1045
|
+
# Creates a task and adds it to a queue.
|
1046
|
+
#
|
1047
|
+
# Tasks cannot be updated after creation; there is no UpdateTask command.
|
1048
|
+
#
|
1049
|
+
# * For {Google::Cloud::Tasks::V2beta3::AppEngineHttpQueue App Engine queues}, the maximum task size is
|
1050
|
+
# 100KB.
|
1051
|
+
#
|
1052
|
+
# @param parent [String]
|
1053
|
+
# Required.
|
1054
|
+
#
|
1055
|
+
# The queue name. For example:
|
1056
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
|
1057
|
+
#
|
1058
|
+
# The queue must already exist.
|
1059
|
+
# @param task [Google::Cloud::Tasks::V2beta3::Task | Hash]
|
1060
|
+
# Required.
|
1061
|
+
#
|
1062
|
+
# The task to add.
|
1063
|
+
#
|
1064
|
+
# Task names have the following format:
|
1065
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`.
|
1066
|
+
# The user can optionally specify a task {Google::Cloud::Tasks::V2beta3::Task#name name}. If a
|
1067
|
+
# name is not specified then the system will generate a random
|
1068
|
+
# unique task id, which will be set in the task returned in the
|
1069
|
+
# {Google::Cloud::Tasks::V2beta3::Task#name response}.
|
1070
|
+
#
|
1071
|
+
# If {Google::Cloud::Tasks::V2beta3::Task#schedule_time schedule_time} is not set or is in the
|
1072
|
+
# past then Cloud Tasks will set it to the current time.
|
1073
|
+
#
|
1074
|
+
# Task De-duplication:
|
1075
|
+
#
|
1076
|
+
# Explicitly specifying a task ID enables task de-duplication. If
|
1077
|
+
# a task's ID is identical to that of an existing task or a task
|
1078
|
+
# that was deleted or executed recently then the call will fail
|
1079
|
+
# with {Google::Rpc::Code::ALREADY_EXISTS ALREADY_EXISTS}.
|
1080
|
+
# If the task's queue was created using Cloud Tasks, then another task with
|
1081
|
+
# the same name can't be created for ~1hour after the original task was
|
1082
|
+
# deleted or executed. If the task's queue was created using queue.yaml or
|
1083
|
+
# queue.xml, then another task with the same name can't be created
|
1084
|
+
# for ~9days after the original task was deleted or executed.
|
1085
|
+
#
|
1086
|
+
# Because there is an extra lookup cost to identify duplicate task
|
1087
|
+
# names, these {Google::Cloud::Tasks::V2beta3::CloudTasks::CreateTask CreateTask} calls have significantly
|
1088
|
+
# increased latency. Using hashed strings for the task id or for
|
1089
|
+
# the prefix of the task id is recommended. Choosing task ids that
|
1090
|
+
# are sequential or have sequential prefixes, for example using a
|
1091
|
+
# timestamp, causes an increase in latency and error rates in all
|
1092
|
+
# task commands. The infrastructure relies on an approximately
|
1093
|
+
# uniform distribution of task ids to store and serve tasks
|
1094
|
+
# efficiently.
|
1095
|
+
# A hash of the same form as `Google::Cloud::Tasks::V2beta3::Task`
|
1096
|
+
# can also be provided.
|
1097
|
+
# @param response_view [Google::Cloud::Tasks::V2beta3::Task::View]
|
1098
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta3::Task Task} will be
|
1099
|
+
# returned.
|
1100
|
+
#
|
1101
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC}; not all
|
1102
|
+
# information is retrieved by default because some data, such as
|
1103
|
+
# payloads, might be desirable to return only when needed because
|
1104
|
+
# of its large size or because of the sensitivity of data that it
|
1105
|
+
# contains.
|
1106
|
+
#
|
1107
|
+
# Authorization for {Google::Cloud::Tasks::V2beta3::Task::View::FULL FULL} requires
|
1108
|
+
# `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
|
1109
|
+
# permission on the {Google::Cloud::Tasks::V2beta3::Task Task} resource.
|
1110
|
+
# @param options [Google::Gax::CallOptions]
|
1111
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1112
|
+
# retries, etc.
|
1113
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1114
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Task]
|
1115
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1116
|
+
# @return [Google::Cloud::Tasks::V2beta3::Task]
|
1117
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1118
|
+
# @example
|
1119
|
+
# require "google/cloud/tasks"
|
1120
|
+
#
|
1121
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
1122
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
1123
|
+
#
|
1124
|
+
# # TODO: Initialize `task`:
|
1125
|
+
# task = {}
|
1126
|
+
# response = cloud_tasks_client.create_task(formatted_parent, task)
|
1127
|
+
|
1128
|
+
def create_task \
|
1129
|
+
parent,
|
1130
|
+
task,
|
1131
|
+
response_view: nil,
|
1132
|
+
options: nil,
|
1133
|
+
&block
|
1134
|
+
req = {
|
1135
|
+
parent: parent,
|
1136
|
+
task: task,
|
1137
|
+
response_view: response_view
|
1138
|
+
}.delete_if { |_, v| v.nil? }
|
1139
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::CreateTaskRequest)
|
1140
|
+
@create_task.call(req, options, &block)
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
# Deletes a task.
|
1144
|
+
#
|
1145
|
+
# A task can be deleted if it is scheduled or dispatched. A task
|
1146
|
+
# cannot be deleted if it has executed successfully or permanently
|
1147
|
+
# failed.
|
1148
|
+
#
|
1149
|
+
# @param name [String]
|
1150
|
+
# Required.
|
1151
|
+
#
|
1152
|
+
# The task name. For example:
|
1153
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
|
1154
|
+
# @param options [Google::Gax::CallOptions]
|
1155
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1156
|
+
# retries, etc.
|
1157
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1158
|
+
# @yieldparam result []
|
1159
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1160
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1161
|
+
# @example
|
1162
|
+
# require "google/cloud/tasks"
|
1163
|
+
#
|
1164
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
1165
|
+
# formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
1166
|
+
# cloud_tasks_client.delete_task(formatted_name)
|
1167
|
+
|
1168
|
+
def delete_task \
|
1169
|
+
name,
|
1170
|
+
options: nil,
|
1171
|
+
&block
|
1172
|
+
req = {
|
1173
|
+
name: name
|
1174
|
+
}.delete_if { |_, v| v.nil? }
|
1175
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::DeleteTaskRequest)
|
1176
|
+
@delete_task.call(req, options, &block)
|
1177
|
+
nil
|
1178
|
+
end
|
1179
|
+
|
1180
|
+
# Forces a task to run now.
|
1181
|
+
#
|
1182
|
+
# When this method is called, Cloud Tasks will dispatch the task, even if
|
1183
|
+
# the task is already running, the queue has reached its {Google::Cloud::Tasks::V2beta3::RateLimits RateLimits} or
|
1184
|
+
# is {Google::Cloud::Tasks::V2beta3::Queue::State::PAUSED PAUSED}.
|
1185
|
+
#
|
1186
|
+
# This command is meant to be used for manual debugging. For
|
1187
|
+
# example, {Google::Cloud::Tasks::V2beta3::CloudTasks::RunTask RunTask} can be used to retry a failed
|
1188
|
+
# task after a fix has been made or to manually force a task to be
|
1189
|
+
# dispatched now.
|
1190
|
+
#
|
1191
|
+
# The dispatched task is returned. That is, the task that is returned
|
1192
|
+
# contains the {Task#status status} after the task is dispatched but
|
1193
|
+
# before the task is received by its target.
|
1194
|
+
#
|
1195
|
+
# If Cloud Tasks receives a successful response from the task's
|
1196
|
+
# target, then the task will be deleted; otherwise the task's
|
1197
|
+
# {Google::Cloud::Tasks::V2beta3::Task#schedule_time schedule_time} will be reset to the time that
|
1198
|
+
# {Google::Cloud::Tasks::V2beta3::CloudTasks::RunTask RunTask} was called plus the retry delay specified
|
1199
|
+
# in the queue's {Google::Cloud::Tasks::V2beta3::RetryConfig RetryConfig}.
|
1200
|
+
#
|
1201
|
+
# {Google::Cloud::Tasks::V2beta3::CloudTasks::RunTask RunTask} returns
|
1202
|
+
# {Google::Rpc::Code::NOT_FOUND NOT_FOUND} when it is called on a
|
1203
|
+
# task that has already succeeded or permanently failed.
|
1204
|
+
#
|
1205
|
+
# @param name [String]
|
1206
|
+
# Required.
|
1207
|
+
#
|
1208
|
+
# The task name. For example:
|
1209
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
|
1210
|
+
# @param response_view [Google::Cloud::Tasks::V2beta3::Task::View]
|
1211
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta3::Task Task} will be
|
1212
|
+
# returned.
|
1213
|
+
#
|
1214
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC}; not all
|
1215
|
+
# information is retrieved by default because some data, such as
|
1216
|
+
# payloads, might be desirable to return only when needed because
|
1217
|
+
# of its large size or because of the sensitivity of data that it
|
1218
|
+
# contains.
|
1219
|
+
#
|
1220
|
+
# Authorization for {Google::Cloud::Tasks::V2beta3::Task::View::FULL FULL} requires
|
1221
|
+
# `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
|
1222
|
+
# permission on the {Google::Cloud::Tasks::V2beta3::Task Task} resource.
|
1223
|
+
# @param options [Google::Gax::CallOptions]
|
1224
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1225
|
+
# retries, etc.
|
1226
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1227
|
+
# @yieldparam result [Google::Cloud::Tasks::V2beta3::Task]
|
1228
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1229
|
+
# @return [Google::Cloud::Tasks::V2beta3::Task]
|
1230
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1231
|
+
# @example
|
1232
|
+
# require "google/cloud/tasks"
|
1233
|
+
#
|
1234
|
+
# cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
|
1235
|
+
# formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
1236
|
+
# response = cloud_tasks_client.run_task(formatted_name)
|
1237
|
+
|
1238
|
+
def run_task \
|
1239
|
+
name,
|
1240
|
+
response_view: nil,
|
1241
|
+
options: nil,
|
1242
|
+
&block
|
1243
|
+
req = {
|
1244
|
+
name: name,
|
1245
|
+
response_view: response_view
|
1246
|
+
}.delete_if { |_, v| v.nil? }
|
1247
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::RunTaskRequest)
|
1248
|
+
@run_task.call(req, options, &block)
|
1249
|
+
end
|
1250
|
+
end
|
1251
|
+
end
|
1252
|
+
end
|
1253
|
+
end
|
1254
|
+
end
|