google-cloud-tasks 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +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,1446 @@
|
|
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/v2beta2/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
|
+
require "json"
|
23
|
+
require "pathname"
|
24
|
+
|
25
|
+
require "google/gax"
|
26
|
+
|
27
|
+
require "google/cloud/tasks/v2beta2/cloudtasks_pb"
|
28
|
+
require "google/cloud/tasks/credentials"
|
29
|
+
|
30
|
+
module Google
|
31
|
+
module Cloud
|
32
|
+
module Tasks
|
33
|
+
module V2beta2
|
34
|
+
# Cloud Tasks allows developers to manage the execution of background
|
35
|
+
# work in their applications.
|
36
|
+
#
|
37
|
+
# @!attribute [r] cloud_tasks_stub
|
38
|
+
# @return [Google::Cloud::Tasks::V2beta2::CloudTasks::Stub]
|
39
|
+
class CloudTasksClient
|
40
|
+
attr_reader :cloud_tasks_stub
|
41
|
+
|
42
|
+
# The default address of the service.
|
43
|
+
SERVICE_ADDRESS = "cloudtasks.googleapis.com".freeze
|
44
|
+
|
45
|
+
# The default port of the service.
|
46
|
+
DEFAULT_SERVICE_PORT = 443
|
47
|
+
|
48
|
+
DEFAULT_TIMEOUT = 30
|
49
|
+
|
50
|
+
PAGE_DESCRIPTORS = {
|
51
|
+
"list_queues" => Google::Gax::PageDescriptor.new(
|
52
|
+
"page_token",
|
53
|
+
"next_page_token",
|
54
|
+
"queues"),
|
55
|
+
"list_tasks" => Google::Gax::PageDescriptor.new(
|
56
|
+
"page_token",
|
57
|
+
"next_page_token",
|
58
|
+
"tasks")
|
59
|
+
}.freeze
|
60
|
+
|
61
|
+
private_constant :PAGE_DESCRIPTORS
|
62
|
+
|
63
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
64
|
+
# this service.
|
65
|
+
ALL_SCOPES = [
|
66
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
67
|
+
].freeze
|
68
|
+
|
69
|
+
|
70
|
+
LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
71
|
+
"projects/{project}/locations/{location}"
|
72
|
+
)
|
73
|
+
|
74
|
+
private_constant :LOCATION_PATH_TEMPLATE
|
75
|
+
|
76
|
+
QUEUE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
77
|
+
"projects/{project}/locations/{location}/queues/{queue}"
|
78
|
+
)
|
79
|
+
|
80
|
+
private_constant :QUEUE_PATH_TEMPLATE
|
81
|
+
|
82
|
+
TASK_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
83
|
+
"projects/{project}/locations/{location}/queues/{queue}/tasks/{task}"
|
84
|
+
)
|
85
|
+
|
86
|
+
private_constant :TASK_PATH_TEMPLATE
|
87
|
+
|
88
|
+
# Returns a fully-qualified location resource name string.
|
89
|
+
# @param project [String]
|
90
|
+
# @param location [String]
|
91
|
+
# @return [String]
|
92
|
+
def self.location_path project, location
|
93
|
+
LOCATION_PATH_TEMPLATE.render(
|
94
|
+
:"project" => project,
|
95
|
+
:"location" => location
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns a fully-qualified queue resource name string.
|
100
|
+
# @param project [String]
|
101
|
+
# @param location [String]
|
102
|
+
# @param queue [String]
|
103
|
+
# @return [String]
|
104
|
+
def self.queue_path project, location, queue
|
105
|
+
QUEUE_PATH_TEMPLATE.render(
|
106
|
+
:"project" => project,
|
107
|
+
:"location" => location,
|
108
|
+
:"queue" => queue
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returns a fully-qualified task resource name string.
|
113
|
+
# @param project [String]
|
114
|
+
# @param location [String]
|
115
|
+
# @param queue [String]
|
116
|
+
# @param task [String]
|
117
|
+
# @return [String]
|
118
|
+
def self.task_path project, location, queue, task
|
119
|
+
TASK_PATH_TEMPLATE.render(
|
120
|
+
:"project" => project,
|
121
|
+
:"location" => location,
|
122
|
+
:"queue" => queue,
|
123
|
+
:"task" => task
|
124
|
+
)
|
125
|
+
end
|
126
|
+
|
127
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
128
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
129
|
+
# be many types.
|
130
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
131
|
+
# authenticating requests made by this client.
|
132
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
133
|
+
# credentials for this client.
|
134
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
135
|
+
# credentials for this client.
|
136
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
137
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
138
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
139
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
140
|
+
# metadata for requests, generally, to give OAuth credentials.
|
141
|
+
# @param scopes [Array<String>]
|
142
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
143
|
+
# an updater_proc is supplied.
|
144
|
+
# @param client_config [Hash]
|
145
|
+
# A Hash for call options for each method. See
|
146
|
+
# Google::Gax#construct_settings for the structure of
|
147
|
+
# this data. Falls back to the default config if not specified
|
148
|
+
# or the specified config is missing data points.
|
149
|
+
# @param timeout [Numeric]
|
150
|
+
# The default timeout, in seconds, for calls made through this client.
|
151
|
+
def initialize \
|
152
|
+
credentials: nil,
|
153
|
+
scopes: ALL_SCOPES,
|
154
|
+
client_config: {},
|
155
|
+
timeout: DEFAULT_TIMEOUT,
|
156
|
+
lib_name: nil,
|
157
|
+
lib_version: ""
|
158
|
+
# These require statements are intentionally placed here to initialize
|
159
|
+
# the gRPC module only when it's required.
|
160
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
161
|
+
require "google/gax/grpc"
|
162
|
+
require "google/cloud/tasks/v2beta2/cloudtasks_services_pb"
|
163
|
+
|
164
|
+
credentials ||= Google::Cloud::Tasks::Credentials.default
|
165
|
+
|
166
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
167
|
+
updater_proc = Google::Cloud::Tasks::Credentials.new(credentials).updater_proc
|
168
|
+
end
|
169
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
170
|
+
channel = credentials
|
171
|
+
end
|
172
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
173
|
+
chan_creds = credentials
|
174
|
+
end
|
175
|
+
if credentials.is_a?(Proc)
|
176
|
+
updater_proc = credentials
|
177
|
+
end
|
178
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
179
|
+
updater_proc = credentials.updater_proc
|
180
|
+
end
|
181
|
+
|
182
|
+
package_version = Gem.loaded_specs['google-cloud-tasks'].version.version
|
183
|
+
|
184
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
185
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
186
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
187
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
188
|
+
google_api_client.freeze
|
189
|
+
|
190
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
191
|
+
client_config_file = Pathname.new(__dir__).join(
|
192
|
+
"cloud_tasks_client_config.json"
|
193
|
+
)
|
194
|
+
defaults = client_config_file.open do |f|
|
195
|
+
Google::Gax.construct_settings(
|
196
|
+
"google.cloud.tasks.v2beta2.CloudTasks",
|
197
|
+
JSON.parse(f.read),
|
198
|
+
client_config,
|
199
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
200
|
+
timeout,
|
201
|
+
page_descriptors: PAGE_DESCRIPTORS,
|
202
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
203
|
+
kwargs: headers
|
204
|
+
)
|
205
|
+
end
|
206
|
+
|
207
|
+
# Allow overriding the service path/port in subclasses.
|
208
|
+
service_path = self.class::SERVICE_ADDRESS
|
209
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
210
|
+
@cloud_tasks_stub = Google::Gax::Grpc.create_stub(
|
211
|
+
service_path,
|
212
|
+
port,
|
213
|
+
chan_creds: chan_creds,
|
214
|
+
channel: channel,
|
215
|
+
updater_proc: updater_proc,
|
216
|
+
scopes: scopes,
|
217
|
+
&Google::Cloud::Tasks::V2beta2::CloudTasks::Stub.method(:new)
|
218
|
+
)
|
219
|
+
|
220
|
+
@list_queues = Google::Gax.create_api_call(
|
221
|
+
@cloud_tasks_stub.method(:list_queues),
|
222
|
+
defaults["list_queues"]
|
223
|
+
)
|
224
|
+
@get_queue = Google::Gax.create_api_call(
|
225
|
+
@cloud_tasks_stub.method(:get_queue),
|
226
|
+
defaults["get_queue"]
|
227
|
+
)
|
228
|
+
@create_queue = Google::Gax.create_api_call(
|
229
|
+
@cloud_tasks_stub.method(:create_queue),
|
230
|
+
defaults["create_queue"]
|
231
|
+
)
|
232
|
+
@update_queue = Google::Gax.create_api_call(
|
233
|
+
@cloud_tasks_stub.method(:update_queue),
|
234
|
+
defaults["update_queue"]
|
235
|
+
)
|
236
|
+
@delete_queue = Google::Gax.create_api_call(
|
237
|
+
@cloud_tasks_stub.method(:delete_queue),
|
238
|
+
defaults["delete_queue"]
|
239
|
+
)
|
240
|
+
@purge_queue = Google::Gax.create_api_call(
|
241
|
+
@cloud_tasks_stub.method(:purge_queue),
|
242
|
+
defaults["purge_queue"]
|
243
|
+
)
|
244
|
+
@pause_queue = Google::Gax.create_api_call(
|
245
|
+
@cloud_tasks_stub.method(:pause_queue),
|
246
|
+
defaults["pause_queue"]
|
247
|
+
)
|
248
|
+
@resume_queue = Google::Gax.create_api_call(
|
249
|
+
@cloud_tasks_stub.method(:resume_queue),
|
250
|
+
defaults["resume_queue"]
|
251
|
+
)
|
252
|
+
@get_iam_policy = Google::Gax.create_api_call(
|
253
|
+
@cloud_tasks_stub.method(:get_iam_policy),
|
254
|
+
defaults["get_iam_policy"]
|
255
|
+
)
|
256
|
+
@set_iam_policy = Google::Gax.create_api_call(
|
257
|
+
@cloud_tasks_stub.method(:set_iam_policy),
|
258
|
+
defaults["set_iam_policy"]
|
259
|
+
)
|
260
|
+
@test_iam_permissions = Google::Gax.create_api_call(
|
261
|
+
@cloud_tasks_stub.method(:test_iam_permissions),
|
262
|
+
defaults["test_iam_permissions"]
|
263
|
+
)
|
264
|
+
@list_tasks = Google::Gax.create_api_call(
|
265
|
+
@cloud_tasks_stub.method(:list_tasks),
|
266
|
+
defaults["list_tasks"]
|
267
|
+
)
|
268
|
+
@get_task = Google::Gax.create_api_call(
|
269
|
+
@cloud_tasks_stub.method(:get_task),
|
270
|
+
defaults["get_task"]
|
271
|
+
)
|
272
|
+
@create_task = Google::Gax.create_api_call(
|
273
|
+
@cloud_tasks_stub.method(:create_task),
|
274
|
+
defaults["create_task"]
|
275
|
+
)
|
276
|
+
@delete_task = Google::Gax.create_api_call(
|
277
|
+
@cloud_tasks_stub.method(:delete_task),
|
278
|
+
defaults["delete_task"]
|
279
|
+
)
|
280
|
+
@lease_tasks = Google::Gax.create_api_call(
|
281
|
+
@cloud_tasks_stub.method(:lease_tasks),
|
282
|
+
defaults["lease_tasks"]
|
283
|
+
)
|
284
|
+
@acknowledge_task = Google::Gax.create_api_call(
|
285
|
+
@cloud_tasks_stub.method(:acknowledge_task),
|
286
|
+
defaults["acknowledge_task"]
|
287
|
+
)
|
288
|
+
@renew_lease = Google::Gax.create_api_call(
|
289
|
+
@cloud_tasks_stub.method(:renew_lease),
|
290
|
+
defaults["renew_lease"]
|
291
|
+
)
|
292
|
+
@cancel_lease = Google::Gax.create_api_call(
|
293
|
+
@cloud_tasks_stub.method(:cancel_lease),
|
294
|
+
defaults["cancel_lease"]
|
295
|
+
)
|
296
|
+
@run_task = Google::Gax.create_api_call(
|
297
|
+
@cloud_tasks_stub.method(:run_task),
|
298
|
+
defaults["run_task"]
|
299
|
+
)
|
300
|
+
end
|
301
|
+
|
302
|
+
# Service calls
|
303
|
+
|
304
|
+
# Lists queues.
|
305
|
+
#
|
306
|
+
# Queues are returned in lexicographical order.
|
307
|
+
#
|
308
|
+
# @param parent [String]
|
309
|
+
# Required.
|
310
|
+
#
|
311
|
+
# The location name.
|
312
|
+
# For example: +projects/PROJECT_ID/locations/LOCATION_ID+
|
313
|
+
# @param filter [String]
|
314
|
+
# +filter+ can be used to specify a subset of queues. Any {Google::Cloud::Tasks::V2beta2::Queue Queue}
|
315
|
+
# field can be used as a filter and several operators as supported.
|
316
|
+
# For example: +<=, <, >=, >, !=, =, :+. The filter syntax is the same as
|
317
|
+
# described in
|
318
|
+
# [Stackdriver's Advanced Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
|
319
|
+
#
|
320
|
+
# Sample filter "app_engine_http_target: *".
|
321
|
+
#
|
322
|
+
# Note that using filters might cause fewer queues than the
|
323
|
+
# requested_page size to be returned.
|
324
|
+
# @param page_size [Integer]
|
325
|
+
# The maximum number of resources contained in the underlying API
|
326
|
+
# response. If page streaming is performed per-resource, this
|
327
|
+
# parameter does not affect the return value. If page streaming is
|
328
|
+
# performed per-page, this determines the maximum number of
|
329
|
+
# resources in a page.
|
330
|
+
# @param options [Google::Gax::CallOptions]
|
331
|
+
# Overrides the default settings for this call, e.g, timeout,
|
332
|
+
# retries, etc.
|
333
|
+
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Queue>]
|
334
|
+
# An enumerable of Google::Cloud::Tasks::V2beta2::Queue instances.
|
335
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
336
|
+
# operations such as per-page iteration or access to the response
|
337
|
+
# object.
|
338
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
339
|
+
# @example
|
340
|
+
# require "google/cloud/tasks/v2beta2"
|
341
|
+
#
|
342
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
343
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
|
344
|
+
#
|
345
|
+
# # Iterate over all results.
|
346
|
+
# cloud_tasks_client.list_queues(formatted_parent).each do |element|
|
347
|
+
# # Process element.
|
348
|
+
# end
|
349
|
+
#
|
350
|
+
# # Or iterate over results one page at a time.
|
351
|
+
# cloud_tasks_client.list_queues(formatted_parent).each_page do |page|
|
352
|
+
# # Process each page at a time.
|
353
|
+
# page.each do |element|
|
354
|
+
# # Process element.
|
355
|
+
# end
|
356
|
+
# end
|
357
|
+
|
358
|
+
def list_queues \
|
359
|
+
parent,
|
360
|
+
filter: nil,
|
361
|
+
page_size: nil,
|
362
|
+
options: nil
|
363
|
+
req = {
|
364
|
+
parent: parent,
|
365
|
+
filter: filter,
|
366
|
+
page_size: page_size
|
367
|
+
}.delete_if { |_, v| v.nil? }
|
368
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ListQueuesRequest)
|
369
|
+
@list_queues.call(req, options)
|
370
|
+
end
|
371
|
+
|
372
|
+
# Gets a queue.
|
373
|
+
#
|
374
|
+
# @param name [String]
|
375
|
+
# Required.
|
376
|
+
#
|
377
|
+
# The resource name of the queue. For example:
|
378
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
|
379
|
+
# @param options [Google::Gax::CallOptions]
|
380
|
+
# Overrides the default settings for this call, e.g, timeout,
|
381
|
+
# retries, etc.
|
382
|
+
# @return [Google::Cloud::Tasks::V2beta2::Queue]
|
383
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
384
|
+
# @example
|
385
|
+
# require "google/cloud/tasks/v2beta2"
|
386
|
+
#
|
387
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
388
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
389
|
+
# response = cloud_tasks_client.get_queue(formatted_name)
|
390
|
+
|
391
|
+
def get_queue \
|
392
|
+
name,
|
393
|
+
options: nil
|
394
|
+
req = {
|
395
|
+
name: name
|
396
|
+
}.delete_if { |_, v| v.nil? }
|
397
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::GetQueueRequest)
|
398
|
+
@get_queue.call(req, options)
|
399
|
+
end
|
400
|
+
|
401
|
+
# Creates a queue.
|
402
|
+
#
|
403
|
+
# Queues created with this method allow tasks to live for a maximum of 31
|
404
|
+
# days. After a task is 31 days old, the task will be deleted regardless of whether
|
405
|
+
# it was dispatched or not.
|
406
|
+
#
|
407
|
+
# WARNING: Using this method may have unintended side effects if you are
|
408
|
+
# using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues.
|
409
|
+
# Read
|
410
|
+
# [Overview of Queue Management and queue.yaml](https://cloud.google.com/cloud-tasks/docs/queue-yaml)
|
411
|
+
# before using this method.
|
412
|
+
#
|
413
|
+
# @param parent [String]
|
414
|
+
# Required.
|
415
|
+
#
|
416
|
+
# The location name in which the queue will be created.
|
417
|
+
# For example: +projects/PROJECT_ID/locations/LOCATION_ID+
|
418
|
+
#
|
419
|
+
# The list of allowed locations can be obtained by calling Cloud
|
420
|
+
# Tasks' implementation of
|
421
|
+
# {Google::Cloud::Location::Locations::ListLocations ListLocations}.
|
422
|
+
# @param queue [Google::Cloud::Tasks::V2beta2::Queue | Hash]
|
423
|
+
# Required.
|
424
|
+
#
|
425
|
+
# The queue to create.
|
426
|
+
#
|
427
|
+
# {Google::Cloud::Tasks::V2beta2::Queue#name Queue's name} cannot be the same as an existing queue.
|
428
|
+
# A hash of the same form as `Google::Cloud::Tasks::V2beta2::Queue`
|
429
|
+
# can also be provided.
|
430
|
+
# @param options [Google::Gax::CallOptions]
|
431
|
+
# Overrides the default settings for this call, e.g, timeout,
|
432
|
+
# retries, etc.
|
433
|
+
# @return [Google::Cloud::Tasks::V2beta2::Queue]
|
434
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
435
|
+
# @example
|
436
|
+
# require "google/cloud/tasks/v2beta2"
|
437
|
+
#
|
438
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
439
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
|
440
|
+
#
|
441
|
+
# # TODO: Initialize +queue+:
|
442
|
+
# queue = {}
|
443
|
+
# response = cloud_tasks_client.create_queue(formatted_parent, queue)
|
444
|
+
|
445
|
+
def create_queue \
|
446
|
+
parent,
|
447
|
+
queue,
|
448
|
+
options: nil
|
449
|
+
req = {
|
450
|
+
parent: parent,
|
451
|
+
queue: queue
|
452
|
+
}.delete_if { |_, v| v.nil? }
|
453
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CreateQueueRequest)
|
454
|
+
@create_queue.call(req, options)
|
455
|
+
end
|
456
|
+
|
457
|
+
# Updates a queue.
|
458
|
+
#
|
459
|
+
# This method creates the queue if it does not exist and updates
|
460
|
+
# the queue if it does exist.
|
461
|
+
#
|
462
|
+
# Queues created with this method allow tasks to live for a maximum of 31
|
463
|
+
# days. After a task is 31 days old, the task will be deleted regardless of whether
|
464
|
+
# it was dispatched or not.
|
465
|
+
#
|
466
|
+
# WARNING: Using this method may have unintended side effects if you are
|
467
|
+
# using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues.
|
468
|
+
# Read
|
469
|
+
# [Overview of Queue Management and queue.yaml](https://cloud.google.com/cloud-tasks/docs/queue-yaml)
|
470
|
+
# before using this method.
|
471
|
+
#
|
472
|
+
# @param queue [Google::Cloud::Tasks::V2beta2::Queue | Hash]
|
473
|
+
# Required.
|
474
|
+
#
|
475
|
+
# The queue to create or update.
|
476
|
+
#
|
477
|
+
# The queue's {Google::Cloud::Tasks::V2beta2::Queue#name name} must be specified.
|
478
|
+
#
|
479
|
+
# Output only fields cannot be modified using UpdateQueue.
|
480
|
+
# Any value specified for an output only field will be ignored.
|
481
|
+
# The queue's {Google::Cloud::Tasks::V2beta2::Queue#name name} cannot be changed.
|
482
|
+
# A hash of the same form as `Google::Cloud::Tasks::V2beta2::Queue`
|
483
|
+
# can also be provided.
|
484
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
485
|
+
# A mask used to specify which fields of the queue are being updated.
|
486
|
+
#
|
487
|
+
# If empty, then all fields will be updated.
|
488
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
489
|
+
# can also be provided.
|
490
|
+
# @param options [Google::Gax::CallOptions]
|
491
|
+
# Overrides the default settings for this call, e.g, timeout,
|
492
|
+
# retries, etc.
|
493
|
+
# @return [Google::Cloud::Tasks::V2beta2::Queue]
|
494
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
495
|
+
# @example
|
496
|
+
# require "google/cloud/tasks/v2beta2"
|
497
|
+
#
|
498
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
499
|
+
#
|
500
|
+
# # TODO: Initialize +queue+:
|
501
|
+
# queue = {}
|
502
|
+
# response = cloud_tasks_client.update_queue(queue)
|
503
|
+
|
504
|
+
def update_queue \
|
505
|
+
queue,
|
506
|
+
update_mask: nil,
|
507
|
+
options: nil
|
508
|
+
req = {
|
509
|
+
queue: queue,
|
510
|
+
update_mask: update_mask
|
511
|
+
}.delete_if { |_, v| v.nil? }
|
512
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::UpdateQueueRequest)
|
513
|
+
@update_queue.call(req, options)
|
514
|
+
end
|
515
|
+
|
516
|
+
# Deletes a queue.
|
517
|
+
#
|
518
|
+
# This command will delete the queue even if it has tasks in it.
|
519
|
+
#
|
520
|
+
# Note: If you delete a queue, a queue with the same name can't be created
|
521
|
+
# for 7 days.
|
522
|
+
#
|
523
|
+
# WARNING: Using this method may have unintended side effects if you are
|
524
|
+
# using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues.
|
525
|
+
# Read
|
526
|
+
# [Overview of Queue Management and queue.yaml](https://cloud.google.com/cloud-tasks/docs/queue-yaml)
|
527
|
+
# before using this method.
|
528
|
+
#
|
529
|
+
# @param name [String]
|
530
|
+
# Required.
|
531
|
+
#
|
532
|
+
# The queue name. For example:
|
533
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
|
534
|
+
# @param options [Google::Gax::CallOptions]
|
535
|
+
# Overrides the default settings for this call, e.g, timeout,
|
536
|
+
# retries, etc.
|
537
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
538
|
+
# @example
|
539
|
+
# require "google/cloud/tasks/v2beta2"
|
540
|
+
#
|
541
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
542
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
543
|
+
# cloud_tasks_client.delete_queue(formatted_name)
|
544
|
+
|
545
|
+
def delete_queue \
|
546
|
+
name,
|
547
|
+
options: nil
|
548
|
+
req = {
|
549
|
+
name: name
|
550
|
+
}.delete_if { |_, v| v.nil? }
|
551
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::DeleteQueueRequest)
|
552
|
+
@delete_queue.call(req, options)
|
553
|
+
nil
|
554
|
+
end
|
555
|
+
|
556
|
+
# Purges a queue by deleting all of its tasks.
|
557
|
+
#
|
558
|
+
# All tasks created before this method is called are permanently deleted.
|
559
|
+
#
|
560
|
+
# Purge operations can take up to one minute to take effect. Tasks
|
561
|
+
# might be dispatched before the purge takes effect. A purge is irreversible.
|
562
|
+
#
|
563
|
+
# @param name [String]
|
564
|
+
# Required.
|
565
|
+
#
|
566
|
+
# The queue name. For example:
|
567
|
+
# +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+
|
568
|
+
# @param options [Google::Gax::CallOptions]
|
569
|
+
# Overrides the default settings for this call, e.g, timeout,
|
570
|
+
# retries, etc.
|
571
|
+
# @return [Google::Cloud::Tasks::V2beta2::Queue]
|
572
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
573
|
+
# @example
|
574
|
+
# require "google/cloud/tasks/v2beta2"
|
575
|
+
#
|
576
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
577
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
578
|
+
# response = cloud_tasks_client.purge_queue(formatted_name)
|
579
|
+
|
580
|
+
def purge_queue \
|
581
|
+
name,
|
582
|
+
options: nil
|
583
|
+
req = {
|
584
|
+
name: name
|
585
|
+
}.delete_if { |_, v| v.nil? }
|
586
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::PurgeQueueRequest)
|
587
|
+
@purge_queue.call(req, options)
|
588
|
+
end
|
589
|
+
|
590
|
+
# Pauses the queue.
|
591
|
+
#
|
592
|
+
# If a queue is paused then the system will stop dispatching tasks
|
593
|
+
# until the queue is resumed via
|
594
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::ResumeQueue ResumeQueue}. Tasks can still be added
|
595
|
+
# when the queue is paused. A queue is paused if its
|
596
|
+
# {Google::Cloud::Tasks::V2beta2::Queue#state state} is {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
|
597
|
+
#
|
598
|
+
# @param name [String]
|
599
|
+
# Required.
|
600
|
+
#
|
601
|
+
# The queue name. For example:
|
602
|
+
# +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+
|
603
|
+
# @param options [Google::Gax::CallOptions]
|
604
|
+
# Overrides the default settings for this call, e.g, timeout,
|
605
|
+
# retries, etc.
|
606
|
+
# @return [Google::Cloud::Tasks::V2beta2::Queue]
|
607
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
608
|
+
# @example
|
609
|
+
# require "google/cloud/tasks/v2beta2"
|
610
|
+
#
|
611
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
612
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
613
|
+
# response = cloud_tasks_client.pause_queue(formatted_name)
|
614
|
+
|
615
|
+
def pause_queue \
|
616
|
+
name,
|
617
|
+
options: nil
|
618
|
+
req = {
|
619
|
+
name: name
|
620
|
+
}.delete_if { |_, v| v.nil? }
|
621
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::PauseQueueRequest)
|
622
|
+
@pause_queue.call(req, options)
|
623
|
+
end
|
624
|
+
|
625
|
+
# Resume a queue.
|
626
|
+
#
|
627
|
+
# This method resumes a queue after it has been
|
628
|
+
# {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED} or
|
629
|
+
# {Google::Cloud::Tasks::V2beta2::Queue::State::DISABLED DISABLED}. The state of a queue is stored
|
630
|
+
# in the queue's {Google::Cloud::Tasks::V2beta2::Queue#state state}; after calling this method it
|
631
|
+
# will be set to {Google::Cloud::Tasks::V2beta2::Queue::State::RUNNING RUNNING}.
|
632
|
+
#
|
633
|
+
# WARNING: Resuming many high-QPS queues at the same time can
|
634
|
+
# lead to target overloading. If you are resuming high-QPS
|
635
|
+
# queues, follow the 500/50/5 pattern described in
|
636
|
+
# [Managing Cloud Tasks Scaling Risks](https://cloud.google.com/cloud-tasks/pdfs/managing-cloud-tasks-scaling-risks-2017-06-05.pdf).
|
637
|
+
#
|
638
|
+
# @param name [String]
|
639
|
+
# Required.
|
640
|
+
#
|
641
|
+
# The queue name. For example:
|
642
|
+
# +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+
|
643
|
+
# @param options [Google::Gax::CallOptions]
|
644
|
+
# Overrides the default settings for this call, e.g, timeout,
|
645
|
+
# retries, etc.
|
646
|
+
# @return [Google::Cloud::Tasks::V2beta2::Queue]
|
647
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
648
|
+
# @example
|
649
|
+
# require "google/cloud/tasks/v2beta2"
|
650
|
+
#
|
651
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
652
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
653
|
+
# response = cloud_tasks_client.resume_queue(formatted_name)
|
654
|
+
|
655
|
+
def resume_queue \
|
656
|
+
name,
|
657
|
+
options: nil
|
658
|
+
req = {
|
659
|
+
name: name
|
660
|
+
}.delete_if { |_, v| v.nil? }
|
661
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ResumeQueueRequest)
|
662
|
+
@resume_queue.call(req, options)
|
663
|
+
end
|
664
|
+
|
665
|
+
# Gets the access control policy for a {Google::Cloud::Tasks::V2beta2::Queue Queue}.
|
666
|
+
# Returns an empty policy if the resource exists and does not have a policy
|
667
|
+
# set.
|
668
|
+
#
|
669
|
+
# Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the
|
670
|
+
# specified resource parent:
|
671
|
+
#
|
672
|
+
# * +cloudtasks.queues.getIamPolicy+
|
673
|
+
#
|
674
|
+
# @param resource [String]
|
675
|
+
# REQUIRED: The resource for which the policy is being requested.
|
676
|
+
# +resource+ is usually specified as a path. For example, a Project
|
677
|
+
# resource is specified as +projects/{project}+.
|
678
|
+
# @param options [Google::Gax::CallOptions]
|
679
|
+
# Overrides the default settings for this call, e.g, timeout,
|
680
|
+
# retries, etc.
|
681
|
+
# @return [Google::Iam::V1::Policy]
|
682
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
683
|
+
# @example
|
684
|
+
# require "google/cloud/tasks/v2beta2"
|
685
|
+
#
|
686
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
687
|
+
# formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
688
|
+
# response = cloud_tasks_client.get_iam_policy(formatted_resource)
|
689
|
+
|
690
|
+
def get_iam_policy \
|
691
|
+
resource,
|
692
|
+
options: nil
|
693
|
+
req = {
|
694
|
+
resource: resource
|
695
|
+
}.delete_if { |_, v| v.nil? }
|
696
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
|
697
|
+
@get_iam_policy.call(req, options)
|
698
|
+
end
|
699
|
+
|
700
|
+
# Sets the access control policy for a {Google::Cloud::Tasks::V2beta2::Queue Queue}. Replaces any existing
|
701
|
+
# policy.
|
702
|
+
#
|
703
|
+
# Note: The Cloud Console does not check queue-level IAM permissions yet.
|
704
|
+
# Project-level permissions are required to use the Cloud Console.
|
705
|
+
#
|
706
|
+
# Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the
|
707
|
+
# specified resource parent:
|
708
|
+
#
|
709
|
+
# * +cloudtasks.queues.setIamPolicy+
|
710
|
+
#
|
711
|
+
# @param resource [String]
|
712
|
+
# REQUIRED: The resource for which the policy is being specified.
|
713
|
+
# +resource+ is usually specified as a path. For example, a Project
|
714
|
+
# resource is specified as +projects/{project}+.
|
715
|
+
# @param policy [Google::Iam::V1::Policy | Hash]
|
716
|
+
# REQUIRED: The complete policy to be applied to the +resource+. The size of
|
717
|
+
# the policy is limited to a few 10s of KB. An empty policy is a
|
718
|
+
# valid policy but certain Cloud Platform services (such as Projects)
|
719
|
+
# might reject them.
|
720
|
+
# A hash of the same form as `Google::Iam::V1::Policy`
|
721
|
+
# can also be provided.
|
722
|
+
# @param options [Google::Gax::CallOptions]
|
723
|
+
# Overrides the default settings for this call, e.g, timeout,
|
724
|
+
# retries, etc.
|
725
|
+
# @return [Google::Iam::V1::Policy]
|
726
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
727
|
+
# @example
|
728
|
+
# require "google/cloud/tasks/v2beta2"
|
729
|
+
#
|
730
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
731
|
+
# formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
732
|
+
#
|
733
|
+
# # TODO: Initialize +policy+:
|
734
|
+
# policy = {}
|
735
|
+
# response = cloud_tasks_client.set_iam_policy(formatted_resource, policy)
|
736
|
+
|
737
|
+
def set_iam_policy \
|
738
|
+
resource,
|
739
|
+
policy,
|
740
|
+
options: nil
|
741
|
+
req = {
|
742
|
+
resource: resource,
|
743
|
+
policy: policy
|
744
|
+
}.delete_if { |_, v| v.nil? }
|
745
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
|
746
|
+
@set_iam_policy.call(req, options)
|
747
|
+
end
|
748
|
+
|
749
|
+
# Returns permissions that a caller has on a {Google::Cloud::Tasks::V2beta2::Queue Queue}.
|
750
|
+
# If the resource does not exist, this will return an empty set of
|
751
|
+
# permissions, not a {Google::Rpc::Code::NOT_FOUND NOT_FOUND} error.
|
752
|
+
#
|
753
|
+
# Note: This operation is designed to be used for building permission-aware
|
754
|
+
# UIs and command-line tools, not for authorization checking. This operation
|
755
|
+
# may "fail open" without warning.
|
756
|
+
#
|
757
|
+
# @param resource [String]
|
758
|
+
# REQUIRED: The resource for which the policy detail is being requested.
|
759
|
+
# +resource+ is usually specified as a path. For example, a Project
|
760
|
+
# resource is specified as +projects/{project}+.
|
761
|
+
# @param permissions [Array<String>]
|
762
|
+
# The set of permissions to check for the +resource+. Permissions with
|
763
|
+
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
764
|
+
# information see
|
765
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
766
|
+
# @param options [Google::Gax::CallOptions]
|
767
|
+
# Overrides the default settings for this call, e.g, timeout,
|
768
|
+
# retries, etc.
|
769
|
+
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
770
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
771
|
+
# @example
|
772
|
+
# require "google/cloud/tasks/v2beta2"
|
773
|
+
#
|
774
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
775
|
+
# formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
776
|
+
#
|
777
|
+
# # TODO: Initialize +permissions+:
|
778
|
+
# permissions = []
|
779
|
+
# response = cloud_tasks_client.test_iam_permissions(formatted_resource, permissions)
|
780
|
+
|
781
|
+
def test_iam_permissions \
|
782
|
+
resource,
|
783
|
+
permissions,
|
784
|
+
options: nil
|
785
|
+
req = {
|
786
|
+
resource: resource,
|
787
|
+
permissions: permissions
|
788
|
+
}.delete_if { |_, v| v.nil? }
|
789
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
|
790
|
+
@test_iam_permissions.call(req, options)
|
791
|
+
end
|
792
|
+
|
793
|
+
# Lists the tasks in a queue.
|
794
|
+
#
|
795
|
+
# By default, only the {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC} view is retrieved
|
796
|
+
# due to performance considerations;
|
797
|
+
# {Google::Cloud::Tasks::V2beta2::ListTasksRequest#response_view response_view} controls the
|
798
|
+
# subset of information which is returned.
|
799
|
+
#
|
800
|
+
# @param parent [String]
|
801
|
+
# Required.
|
802
|
+
#
|
803
|
+
# The queue name. For example:
|
804
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
|
805
|
+
# @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
|
806
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
|
807
|
+
# returned.
|
808
|
+
#
|
809
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
|
810
|
+
# information is retrieved by default because some data, such as
|
811
|
+
# payloads, might be desirable to return only when needed because
|
812
|
+
# of its large size or because of the sensitivity of data that it
|
813
|
+
# contains.
|
814
|
+
#
|
815
|
+
# Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
|
816
|
+
# +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
|
817
|
+
# {Google::Cloud::Tasks::V2beta2::Task Task} resource.
|
818
|
+
# @param order_by [String]
|
819
|
+
# Sort order used for the query. The only fields supported for sorting
|
820
|
+
# are +schedule_time+ and +pull_message.tag+. All results will be
|
821
|
+
# returned in approximately ascending order. The default ordering is by
|
822
|
+
# +schedule_time+.
|
823
|
+
# @param page_size [Integer]
|
824
|
+
# The maximum number of resources contained in the underlying API
|
825
|
+
# response. If page streaming is performed per-resource, this
|
826
|
+
# parameter does not affect the return value. If page streaming is
|
827
|
+
# performed per-page, this determines the maximum number of
|
828
|
+
# resources in a page.
|
829
|
+
# @param options [Google::Gax::CallOptions]
|
830
|
+
# Overrides the default settings for this call, e.g, timeout,
|
831
|
+
# retries, etc.
|
832
|
+
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Task>]
|
833
|
+
# An enumerable of Google::Cloud::Tasks::V2beta2::Task instances.
|
834
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
835
|
+
# operations such as per-page iteration or access to the response
|
836
|
+
# object.
|
837
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
838
|
+
# @example
|
839
|
+
# require "google/cloud/tasks/v2beta2"
|
840
|
+
#
|
841
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
842
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
843
|
+
#
|
844
|
+
# # Iterate over all results.
|
845
|
+
# cloud_tasks_client.list_tasks(formatted_parent).each do |element|
|
846
|
+
# # Process element.
|
847
|
+
# end
|
848
|
+
#
|
849
|
+
# # Or iterate over results one page at a time.
|
850
|
+
# cloud_tasks_client.list_tasks(formatted_parent).each_page do |page|
|
851
|
+
# # Process each page at a time.
|
852
|
+
# page.each do |element|
|
853
|
+
# # Process element.
|
854
|
+
# end
|
855
|
+
# end
|
856
|
+
|
857
|
+
def list_tasks \
|
858
|
+
parent,
|
859
|
+
response_view: nil,
|
860
|
+
order_by: nil,
|
861
|
+
page_size: nil,
|
862
|
+
options: nil
|
863
|
+
req = {
|
864
|
+
parent: parent,
|
865
|
+
response_view: response_view,
|
866
|
+
order_by: order_by,
|
867
|
+
page_size: page_size
|
868
|
+
}.delete_if { |_, v| v.nil? }
|
869
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ListTasksRequest)
|
870
|
+
@list_tasks.call(req, options)
|
871
|
+
end
|
872
|
+
|
873
|
+
# Gets a task.
|
874
|
+
#
|
875
|
+
# @param name [String]
|
876
|
+
# Required.
|
877
|
+
#
|
878
|
+
# The task name. For example:
|
879
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
|
880
|
+
# @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
|
881
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
|
882
|
+
# returned.
|
883
|
+
#
|
884
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
|
885
|
+
# information is retrieved by default because some data, such as
|
886
|
+
# payloads, might be desirable to return only when needed because
|
887
|
+
# of its large size or because of the sensitivity of data that it
|
888
|
+
# contains.
|
889
|
+
#
|
890
|
+
# Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
|
891
|
+
# +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
|
892
|
+
# {Google::Cloud::Tasks::V2beta2::Task Task} resource.
|
893
|
+
# @param options [Google::Gax::CallOptions]
|
894
|
+
# Overrides the default settings for this call, e.g, timeout,
|
895
|
+
# retries, etc.
|
896
|
+
# @return [Google::Cloud::Tasks::V2beta2::Task]
|
897
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
898
|
+
# @example
|
899
|
+
# require "google/cloud/tasks/v2beta2"
|
900
|
+
#
|
901
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
902
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
903
|
+
# response = cloud_tasks_client.get_task(formatted_name)
|
904
|
+
|
905
|
+
def get_task \
|
906
|
+
name,
|
907
|
+
response_view: nil,
|
908
|
+
options: nil
|
909
|
+
req = {
|
910
|
+
name: name,
|
911
|
+
response_view: response_view
|
912
|
+
}.delete_if { |_, v| v.nil? }
|
913
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::GetTaskRequest)
|
914
|
+
@get_task.call(req, options)
|
915
|
+
end
|
916
|
+
|
917
|
+
# Creates a task and adds it to a queue.
|
918
|
+
#
|
919
|
+
# To add multiple tasks at the same time, use
|
920
|
+
# [HTTP batching](https://cloud.google.com/storage/docs/json_api/v1/how-tos/batch)
|
921
|
+
# or the batching documentation for your client library, for example
|
922
|
+
# https://developers.google.com/api-client-library/python/guide/batch.
|
923
|
+
#
|
924
|
+
# Tasks cannot be updated after creation; there is no UpdateTask command.
|
925
|
+
#
|
926
|
+
# * For [App Engine queues](https://cloud.google.comgoogle.cloud.tasks.v2beta2.AppEngineHttpTarget),
|
927
|
+
# the maximum task size is 100KB.
|
928
|
+
# * For [pull queues](https://cloud.google.comgoogle.cloud.tasks.v2beta2.PullTarget), this
|
929
|
+
# the maximum task size is 1MB.
|
930
|
+
#
|
931
|
+
# @param parent [String]
|
932
|
+
# Required.
|
933
|
+
#
|
934
|
+
# The queue name. For example:
|
935
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
|
936
|
+
#
|
937
|
+
# The queue must already exist.
|
938
|
+
# @param task [Google::Cloud::Tasks::V2beta2::Task | Hash]
|
939
|
+
# Required.
|
940
|
+
#
|
941
|
+
# The task to add.
|
942
|
+
#
|
943
|
+
# Task names have the following format:
|
944
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+.
|
945
|
+
# The user can optionally specify a task {Google::Cloud::Tasks::V2beta2::Task#name name}. If a
|
946
|
+
# name is not specified then the system will generate a random
|
947
|
+
# unique task id, which will be set in the task returned in the
|
948
|
+
# {Google::Cloud::Tasks::V2beta2::Task#name response}.
|
949
|
+
#
|
950
|
+
# If {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} is not set or is in the
|
951
|
+
# past then Cloud Tasks will set it to the current time.
|
952
|
+
#
|
953
|
+
# Task De-duplication:
|
954
|
+
#
|
955
|
+
# Explicitly specifying a task ID enables task de-duplication. If
|
956
|
+
# a task's ID is identical to that of an existing task or a task
|
957
|
+
# that was deleted or completed recently then the call will fail
|
958
|
+
# with {Google::Rpc::Code::ALREADY_EXISTS ALREADY_EXISTS}.
|
959
|
+
# If the task's queue was created using Cloud Tasks, then another task with
|
960
|
+
# the same name can't be created for ~1hour after the original task was
|
961
|
+
# deleted or completed. If the task's queue was created using queue.yaml or
|
962
|
+
# queue.xml, then another task with the same name can't be created
|
963
|
+
# for ~9days after the original task was deleted or completed.
|
964
|
+
#
|
965
|
+
# Because there is an extra lookup cost to identify duplicate task
|
966
|
+
# names, these {Google::Cloud::Tasks::V2beta2::CloudTasks::CreateTask CreateTask} calls have significantly
|
967
|
+
# increased latency. Using hashed strings for the task id or for
|
968
|
+
# the prefix of the task id is recommended. Choosing task ids that
|
969
|
+
# are sequential or have sequential prefixes, for example using a
|
970
|
+
# timestamp, causes an increase in latency and error rates in all
|
971
|
+
# task commands. The infrastructure relies on an approximately
|
972
|
+
# uniform distribution of task ids to store and serve tasks
|
973
|
+
# efficiently.
|
974
|
+
# A hash of the same form as `Google::Cloud::Tasks::V2beta2::Task`
|
975
|
+
# can also be provided.
|
976
|
+
# @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
|
977
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
|
978
|
+
# returned.
|
979
|
+
#
|
980
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
|
981
|
+
# information is retrieved by default because some data, such as
|
982
|
+
# payloads, might be desirable to return only when needed because
|
983
|
+
# of its large size or because of the sensitivity of data that it
|
984
|
+
# contains.
|
985
|
+
#
|
986
|
+
# Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
|
987
|
+
# +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
|
988
|
+
# {Google::Cloud::Tasks::V2beta2::Task Task} resource.
|
989
|
+
# @param options [Google::Gax::CallOptions]
|
990
|
+
# Overrides the default settings for this call, e.g, timeout,
|
991
|
+
# retries, etc.
|
992
|
+
# @return [Google::Cloud::Tasks::V2beta2::Task]
|
993
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
994
|
+
# @example
|
995
|
+
# require "google/cloud/tasks/v2beta2"
|
996
|
+
#
|
997
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
998
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
999
|
+
#
|
1000
|
+
# # TODO: Initialize +task+:
|
1001
|
+
# task = {}
|
1002
|
+
# response = cloud_tasks_client.create_task(formatted_parent, task)
|
1003
|
+
|
1004
|
+
def create_task \
|
1005
|
+
parent,
|
1006
|
+
task,
|
1007
|
+
response_view: nil,
|
1008
|
+
options: nil
|
1009
|
+
req = {
|
1010
|
+
parent: parent,
|
1011
|
+
task: task,
|
1012
|
+
response_view: response_view
|
1013
|
+
}.delete_if { |_, v| v.nil? }
|
1014
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CreateTaskRequest)
|
1015
|
+
@create_task.call(req, options)
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
# Deletes a task.
|
1019
|
+
#
|
1020
|
+
# A task can be deleted if it is scheduled or dispatched. A task
|
1021
|
+
# cannot be deleted if it has completed successfully or permanently
|
1022
|
+
# failed.
|
1023
|
+
#
|
1024
|
+
# @param name [String]
|
1025
|
+
# Required.
|
1026
|
+
#
|
1027
|
+
# The task name. For example:
|
1028
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
|
1029
|
+
# @param options [Google::Gax::CallOptions]
|
1030
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1031
|
+
# retries, etc.
|
1032
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1033
|
+
# @example
|
1034
|
+
# require "google/cloud/tasks/v2beta2"
|
1035
|
+
#
|
1036
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
1037
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
1038
|
+
# cloud_tasks_client.delete_task(formatted_name)
|
1039
|
+
|
1040
|
+
def delete_task \
|
1041
|
+
name,
|
1042
|
+
options: nil
|
1043
|
+
req = {
|
1044
|
+
name: name
|
1045
|
+
}.delete_if { |_, v| v.nil? }
|
1046
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::DeleteTaskRequest)
|
1047
|
+
@delete_task.call(req, options)
|
1048
|
+
nil
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
# Leases tasks from a pull queue for
|
1052
|
+
# {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration}.
|
1053
|
+
#
|
1054
|
+
# This method is invoked by the worker to obtain a lease. The
|
1055
|
+
# worker must acknowledge the task via
|
1056
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::AcknowledgeTask AcknowledgeTask} after they have
|
1057
|
+
# performed the work associated with the task.
|
1058
|
+
#
|
1059
|
+
# The {Google::Cloud::Tasks::V2beta2::PullMessage#payload payload} is intended to store data that
|
1060
|
+
# the worker needs to perform the work associated with the task. To
|
1061
|
+
# return the payloads in the {Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response}, set
|
1062
|
+
# {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#response_view response_view} to
|
1063
|
+
# {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL}.
|
1064
|
+
#
|
1065
|
+
# A maximum of 10 qps of {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks}
|
1066
|
+
# requests are allowed per
|
1067
|
+
# queue. {Google::Rpc::Code::RESOURCE_EXHAUSTED RESOURCE_EXHAUSTED}
|
1068
|
+
# is returned when this limit is
|
1069
|
+
# exceeded. {Google::Rpc::Code::RESOURCE_EXHAUSTED RESOURCE_EXHAUSTED}
|
1070
|
+
# is also returned when
|
1071
|
+
# {Google::Cloud::Tasks::V2beta2::RateLimits#max_tasks_dispatched_per_second max_tasks_dispatched_per_second}
|
1072
|
+
# is exceeded.
|
1073
|
+
#
|
1074
|
+
# @param parent [String]
|
1075
|
+
# Required.
|
1076
|
+
#
|
1077
|
+
# The queue name. For example:
|
1078
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
|
1079
|
+
# @param lease_duration [Google::Protobuf::Duration | Hash]
|
1080
|
+
# After the worker has successfully finished the work associated
|
1081
|
+
# with the task, the worker must call via
|
1082
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::AcknowledgeTask AcknowledgeTask} before the
|
1083
|
+
# {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}. Otherwise the task will be
|
1084
|
+
# returned to a later {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} call so
|
1085
|
+
# that another worker can retry it.
|
1086
|
+
#
|
1087
|
+
# The maximum lease duration is 1 week.
|
1088
|
+
# +lease_duration+ will be truncated to the nearest second.
|
1089
|
+
# A hash of the same form as `Google::Protobuf::Duration`
|
1090
|
+
# can also be provided.
|
1091
|
+
# @param max_tasks [Integer]
|
1092
|
+
# The maximum number of tasks to lease. The maximum that can be
|
1093
|
+
# requested is 1000.
|
1094
|
+
# @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
|
1095
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
|
1096
|
+
# returned.
|
1097
|
+
#
|
1098
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
|
1099
|
+
# information is retrieved by default because some data, such as
|
1100
|
+
# payloads, might be desirable to return only when needed because
|
1101
|
+
# of its large size or because of the sensitivity of data that it
|
1102
|
+
# contains.
|
1103
|
+
#
|
1104
|
+
# Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
|
1105
|
+
# +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
|
1106
|
+
# {Google::Cloud::Tasks::V2beta2::Task Task} resource.
|
1107
|
+
# @param filter [String]
|
1108
|
+
# +filter+ can be used to specify a subset of tasks to lease.
|
1109
|
+
#
|
1110
|
+
# When +filter+ is set to +tag=<my-tag>+ then the
|
1111
|
+
# {Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response} will contain only tasks whose
|
1112
|
+
# {Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} is equal to +<my-tag>+. +<my-tag>+ must be
|
1113
|
+
# less than 500 characters.
|
1114
|
+
#
|
1115
|
+
# When +filter+ is set to +tag_function=oldest_tag()+, only tasks which have
|
1116
|
+
# the same tag as the task with the oldest
|
1117
|
+
# {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be returned.
|
1118
|
+
#
|
1119
|
+
# Grammar Syntax:
|
1120
|
+
#
|
1121
|
+
# * +filter = "tag=" tag | "tag_function=" function+
|
1122
|
+
#
|
1123
|
+
# * +tag = string+
|
1124
|
+
#
|
1125
|
+
# * +function = "oldest_tag()"+
|
1126
|
+
#
|
1127
|
+
# The +oldest_tag()+ function returns tasks which have the same tag as the
|
1128
|
+
# oldest task (ordered by schedule time).
|
1129
|
+
#
|
1130
|
+
# SDK compatibility: Although the SDK allows tags to be either
|
1131
|
+
# string or
|
1132
|
+
# [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-),
|
1133
|
+
# only UTF-8 encoded tags can be used in Cloud Tasks. Tag which
|
1134
|
+
# aren't UTF-8 encoded can't be used in the
|
1135
|
+
# {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#filter filter} and the task's
|
1136
|
+
# {Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} will be displayed as empty in Cloud Tasks.
|
1137
|
+
# @param options [Google::Gax::CallOptions]
|
1138
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1139
|
+
# retries, etc.
|
1140
|
+
# @return [Google::Cloud::Tasks::V2beta2::LeaseTasksResponse]
|
1141
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1142
|
+
# @example
|
1143
|
+
# require "google/cloud/tasks/v2beta2"
|
1144
|
+
#
|
1145
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
1146
|
+
# formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
|
1147
|
+
#
|
1148
|
+
# # TODO: Initialize +lease_duration+:
|
1149
|
+
# lease_duration = {}
|
1150
|
+
# response = cloud_tasks_client.lease_tasks(formatted_parent, lease_duration)
|
1151
|
+
|
1152
|
+
def lease_tasks \
|
1153
|
+
parent,
|
1154
|
+
lease_duration,
|
1155
|
+
max_tasks: nil,
|
1156
|
+
response_view: nil,
|
1157
|
+
filter: nil,
|
1158
|
+
options: nil
|
1159
|
+
req = {
|
1160
|
+
parent: parent,
|
1161
|
+
lease_duration: lease_duration,
|
1162
|
+
max_tasks: max_tasks,
|
1163
|
+
response_view: response_view,
|
1164
|
+
filter: filter
|
1165
|
+
}.delete_if { |_, v| v.nil? }
|
1166
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::LeaseTasksRequest)
|
1167
|
+
@lease_tasks.call(req, options)
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
# Acknowledges a pull task.
|
1171
|
+
#
|
1172
|
+
# The worker, that is, the entity that
|
1173
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks leased} this task must call this method
|
1174
|
+
# to indicate that the work associated with the task has finished.
|
1175
|
+
#
|
1176
|
+
# The worker must acknowledge a task within the
|
1177
|
+
# {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration} or the lease
|
1178
|
+
# will expire and the task will become available to be leased
|
1179
|
+
# again. After the task is acknowledged, it will not be returned
|
1180
|
+
# by a later {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks},
|
1181
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::GetTask GetTask}, or
|
1182
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::ListTasks ListTasks}.
|
1183
|
+
#
|
1184
|
+
# To acknowledge multiple tasks at the same time, use
|
1185
|
+
# [HTTP batching](https://cloud.google.com/storage/docs/json_api/v1/how-tos/batch)
|
1186
|
+
# or the batching documentation for your client library, for example
|
1187
|
+
# https://developers.google.com/api-client-library/python/guide/batch.
|
1188
|
+
#
|
1189
|
+
# @param name [String]
|
1190
|
+
# Required.
|
1191
|
+
#
|
1192
|
+
# The task name. For example:
|
1193
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
|
1194
|
+
# @param schedule_time [Google::Protobuf::Timestamp | Hash]
|
1195
|
+
# Required.
|
1196
|
+
#
|
1197
|
+
# The task's current schedule time, available in the
|
1198
|
+
# {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
|
1199
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
|
1200
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
|
1201
|
+
# to ensure that your worker currently holds the lease.
|
1202
|
+
# A hash of the same form as `Google::Protobuf::Timestamp`
|
1203
|
+
# can also be provided.
|
1204
|
+
# @param options [Google::Gax::CallOptions]
|
1205
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1206
|
+
# retries, etc.
|
1207
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1208
|
+
# @example
|
1209
|
+
# require "google/cloud/tasks/v2beta2"
|
1210
|
+
#
|
1211
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
1212
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
1213
|
+
#
|
1214
|
+
# # TODO: Initialize +schedule_time+:
|
1215
|
+
# schedule_time = {}
|
1216
|
+
# cloud_tasks_client.acknowledge_task(formatted_name, schedule_time)
|
1217
|
+
|
1218
|
+
def acknowledge_task \
|
1219
|
+
name,
|
1220
|
+
schedule_time,
|
1221
|
+
options: nil
|
1222
|
+
req = {
|
1223
|
+
name: name,
|
1224
|
+
schedule_time: schedule_time
|
1225
|
+
}.delete_if { |_, v| v.nil? }
|
1226
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest)
|
1227
|
+
@acknowledge_task.call(req, options)
|
1228
|
+
nil
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
# Renew the current lease of a pull task.
|
1232
|
+
#
|
1233
|
+
# The worker can use this method to extend the lease by a new
|
1234
|
+
# duration, starting from now. The new task lease will be
|
1235
|
+
# returned in the task's {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}.
|
1236
|
+
#
|
1237
|
+
# @param name [String]
|
1238
|
+
# Required.
|
1239
|
+
#
|
1240
|
+
# The task name. For example:
|
1241
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
|
1242
|
+
# @param schedule_time [Google::Protobuf::Timestamp | Hash]
|
1243
|
+
# Required.
|
1244
|
+
#
|
1245
|
+
# The task's current schedule time, available in the
|
1246
|
+
# {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
|
1247
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
|
1248
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
|
1249
|
+
# to ensure that your worker currently holds the lease.
|
1250
|
+
# A hash of the same form as `Google::Protobuf::Timestamp`
|
1251
|
+
# can also be provided.
|
1252
|
+
# @param lease_duration [Google::Protobuf::Duration | Hash]
|
1253
|
+
# Required.
|
1254
|
+
#
|
1255
|
+
# The desired new lease duration, starting from now.
|
1256
|
+
#
|
1257
|
+
#
|
1258
|
+
# The maximum lease duration is 1 week.
|
1259
|
+
# +lease_duration+ will be truncated to the nearest second.
|
1260
|
+
# A hash of the same form as `Google::Protobuf::Duration`
|
1261
|
+
# can also be provided.
|
1262
|
+
# @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
|
1263
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
|
1264
|
+
# returned.
|
1265
|
+
#
|
1266
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
|
1267
|
+
# information is retrieved by default because some data, such as
|
1268
|
+
# payloads, might be desirable to return only when needed because
|
1269
|
+
# of its large size or because of the sensitivity of data that it
|
1270
|
+
# contains.
|
1271
|
+
#
|
1272
|
+
# Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
|
1273
|
+
# +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
|
1274
|
+
# {Google::Cloud::Tasks::V2beta2::Task Task} resource.
|
1275
|
+
# @param options [Google::Gax::CallOptions]
|
1276
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1277
|
+
# retries, etc.
|
1278
|
+
# @return [Google::Cloud::Tasks::V2beta2::Task]
|
1279
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1280
|
+
# @example
|
1281
|
+
# require "google/cloud/tasks/v2beta2"
|
1282
|
+
#
|
1283
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
1284
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
1285
|
+
#
|
1286
|
+
# # TODO: Initialize +schedule_time+:
|
1287
|
+
# schedule_time = {}
|
1288
|
+
#
|
1289
|
+
# # TODO: Initialize +lease_duration+:
|
1290
|
+
# lease_duration = {}
|
1291
|
+
# response = cloud_tasks_client.renew_lease(formatted_name, schedule_time, lease_duration)
|
1292
|
+
|
1293
|
+
def renew_lease \
|
1294
|
+
name,
|
1295
|
+
schedule_time,
|
1296
|
+
lease_duration,
|
1297
|
+
response_view: nil,
|
1298
|
+
options: nil
|
1299
|
+
req = {
|
1300
|
+
name: name,
|
1301
|
+
schedule_time: schedule_time,
|
1302
|
+
lease_duration: lease_duration,
|
1303
|
+
response_view: response_view
|
1304
|
+
}.delete_if { |_, v| v.nil? }
|
1305
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::RenewLeaseRequest)
|
1306
|
+
@renew_lease.call(req, options)
|
1307
|
+
end
|
1308
|
+
|
1309
|
+
# Cancel a pull task's lease.
|
1310
|
+
#
|
1311
|
+
# The worker can use this method to cancel a task's lease by
|
1312
|
+
# setting its {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} to now. This will
|
1313
|
+
# make the task available to be leased to the next caller of
|
1314
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks}.
|
1315
|
+
#
|
1316
|
+
# @param name [String]
|
1317
|
+
# Required.
|
1318
|
+
#
|
1319
|
+
# The task name. For example:
|
1320
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
|
1321
|
+
# @param schedule_time [Google::Protobuf::Timestamp | Hash]
|
1322
|
+
# Required.
|
1323
|
+
#
|
1324
|
+
# The task's current schedule time, available in the
|
1325
|
+
# {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
|
1326
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
|
1327
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
|
1328
|
+
# to ensure that your worker currently holds the lease.
|
1329
|
+
# A hash of the same form as `Google::Protobuf::Timestamp`
|
1330
|
+
# can also be provided.
|
1331
|
+
# @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
|
1332
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
|
1333
|
+
# returned.
|
1334
|
+
#
|
1335
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
|
1336
|
+
# information is retrieved by default because some data, such as
|
1337
|
+
# payloads, might be desirable to return only when needed because
|
1338
|
+
# of its large size or because of the sensitivity of data that it
|
1339
|
+
# contains.
|
1340
|
+
#
|
1341
|
+
# Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
|
1342
|
+
# +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
|
1343
|
+
# {Google::Cloud::Tasks::V2beta2::Task Task} resource.
|
1344
|
+
# @param options [Google::Gax::CallOptions]
|
1345
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1346
|
+
# retries, etc.
|
1347
|
+
# @return [Google::Cloud::Tasks::V2beta2::Task]
|
1348
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1349
|
+
# @example
|
1350
|
+
# require "google/cloud/tasks/v2beta2"
|
1351
|
+
#
|
1352
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
1353
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
1354
|
+
#
|
1355
|
+
# # TODO: Initialize +schedule_time+:
|
1356
|
+
# schedule_time = {}
|
1357
|
+
# response = cloud_tasks_client.cancel_lease(formatted_name, schedule_time)
|
1358
|
+
|
1359
|
+
def cancel_lease \
|
1360
|
+
name,
|
1361
|
+
schedule_time,
|
1362
|
+
response_view: nil,
|
1363
|
+
options: nil
|
1364
|
+
req = {
|
1365
|
+
name: name,
|
1366
|
+
schedule_time: schedule_time,
|
1367
|
+
response_view: response_view
|
1368
|
+
}.delete_if { |_, v| v.nil? }
|
1369
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CancelLeaseRequest)
|
1370
|
+
@cancel_lease.call(req, options)
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
# Forces a task to run now.
|
1374
|
+
#
|
1375
|
+
# When this method is called, Cloud Tasks will dispatch the task, even if
|
1376
|
+
# the task is already running, the queue has reached its {Google::Cloud::Tasks::V2beta2::RateLimits RateLimits} or
|
1377
|
+
# is {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
|
1378
|
+
#
|
1379
|
+
# This command is meant to be used for manual debugging. For
|
1380
|
+
# example, {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} can be used to retry a failed
|
1381
|
+
# task after a fix has been made or to manually force a task to be
|
1382
|
+
# dispatched now.
|
1383
|
+
#
|
1384
|
+
# The dispatched task is returned. That is, the task that is returned
|
1385
|
+
# contains the {Google::Cloud::Tasks::V2beta2::Task#status status} after the task is dispatched but
|
1386
|
+
# before the task is received by its target.
|
1387
|
+
#
|
1388
|
+
# If Cloud Tasks receives a successful response from the task's
|
1389
|
+
# target, then the task will be deleted; otherwise the task's
|
1390
|
+
# {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be reset to the time that
|
1391
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} was called plus the retry delay specified
|
1392
|
+
# in the queue's {Google::Cloud::Tasks::V2beta2::RetryConfig RetryConfig}.
|
1393
|
+
#
|
1394
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} returns
|
1395
|
+
# {Google::Rpc::Code::NOT_FOUND NOT_FOUND} when it is called on a
|
1396
|
+
# task that has already succeeded or permanently failed.
|
1397
|
+
#
|
1398
|
+
# {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} cannot be called on a
|
1399
|
+
# {Google::Cloud::Tasks::V2beta2::PullMessage pull task}.
|
1400
|
+
#
|
1401
|
+
# @param name [String]
|
1402
|
+
# Required.
|
1403
|
+
#
|
1404
|
+
# The task name. For example:
|
1405
|
+
# +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
|
1406
|
+
# @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
|
1407
|
+
# The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
|
1408
|
+
# returned.
|
1409
|
+
#
|
1410
|
+
# By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
|
1411
|
+
# information is retrieved by default because some data, such as
|
1412
|
+
# payloads, might be desirable to return only when needed because
|
1413
|
+
# of its large size or because of the sensitivity of data that it
|
1414
|
+
# contains.
|
1415
|
+
#
|
1416
|
+
# Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
|
1417
|
+
# +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
|
1418
|
+
# {Google::Cloud::Tasks::V2beta2::Task Task} resource.
|
1419
|
+
# @param options [Google::Gax::CallOptions]
|
1420
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1421
|
+
# retries, etc.
|
1422
|
+
# @return [Google::Cloud::Tasks::V2beta2::Task]
|
1423
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1424
|
+
# @example
|
1425
|
+
# require "google/cloud/tasks/v2beta2"
|
1426
|
+
#
|
1427
|
+
# cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
|
1428
|
+
# formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
|
1429
|
+
# response = cloud_tasks_client.run_task(formatted_name)
|
1430
|
+
|
1431
|
+
def run_task \
|
1432
|
+
name,
|
1433
|
+
response_view: nil,
|
1434
|
+
options: nil
|
1435
|
+
req = {
|
1436
|
+
name: name,
|
1437
|
+
response_view: response_view
|
1438
|
+
}.delete_if { |_, v| v.nil? }
|
1439
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::RunTaskRequest)
|
1440
|
+
@run_task.call(req, options)
|
1441
|
+
end
|
1442
|
+
end
|
1443
|
+
end
|
1444
|
+
end
|
1445
|
+
end
|
1446
|
+
end
|