google-cloud-tasks-v2beta2 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2220 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/tasks/v2beta2/cloudtasks_pb"
21
+ require "google/cloud/tasks/v2beta2/cloud_tasks/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Tasks
26
+ module V2beta2
27
+ module CloudTasks
28
+ module Rest
29
+ ##
30
+ # REST client for the CloudTasks service.
31
+ #
32
+ # Cloud Tasks allows developers to manage the execution of background
33
+ # work in their applications.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :cloud_tasks_stub
40
+
41
+ ##
42
+ # Configure the CloudTasks Client class.
43
+ #
44
+ # See {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all CloudTasks clients
50
+ # ::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "Tasks", "V2beta2"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.rpcs.list_queues.timeout = 20.0
71
+ default_config.rpcs.list_queues.retry_policy = {
72
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
73
+ }
74
+
75
+ default_config.rpcs.get_queue.timeout = 20.0
76
+ default_config.rpcs.get_queue.retry_policy = {
77
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
78
+ }
79
+
80
+ default_config.rpcs.create_queue.timeout = 20.0
81
+
82
+ default_config.rpcs.update_queue.timeout = 20.0
83
+
84
+ default_config.rpcs.delete_queue.timeout = 20.0
85
+ default_config.rpcs.delete_queue.retry_policy = {
86
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
87
+ }
88
+
89
+ default_config.rpcs.purge_queue.timeout = 20.0
90
+
91
+ default_config.rpcs.pause_queue.timeout = 20.0
92
+
93
+ default_config.rpcs.resume_queue.timeout = 20.0
94
+
95
+ default_config.rpcs.get_iam_policy.timeout = 20.0
96
+ default_config.rpcs.get_iam_policy.retry_policy = {
97
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
98
+ }
99
+
100
+ default_config.rpcs.set_iam_policy.timeout = 20.0
101
+
102
+ default_config.rpcs.test_iam_permissions.timeout = 20.0
103
+ default_config.rpcs.test_iam_permissions.retry_policy = {
104
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
105
+ }
106
+
107
+ default_config.rpcs.list_tasks.timeout = 20.0
108
+ default_config.rpcs.list_tasks.retry_policy = {
109
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
110
+ }
111
+
112
+ default_config.rpcs.get_task.timeout = 20.0
113
+ default_config.rpcs.get_task.retry_policy = {
114
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
115
+ }
116
+
117
+ default_config.rpcs.create_task.timeout = 20.0
118
+
119
+ default_config.rpcs.delete_task.timeout = 20.0
120
+ default_config.rpcs.delete_task.retry_policy = {
121
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
122
+ }
123
+
124
+ default_config.rpcs.lease_tasks.timeout = 20.0
125
+
126
+ default_config.rpcs.acknowledge_task.timeout = 20.0
127
+
128
+ default_config.rpcs.renew_lease.timeout = 20.0
129
+
130
+ default_config.rpcs.cancel_lease.timeout = 20.0
131
+
132
+ default_config.rpcs.run_task.timeout = 20.0
133
+
134
+ default_config
135
+ end
136
+ yield @configure if block_given?
137
+ @configure
138
+ end
139
+
140
+ ##
141
+ # Configure the CloudTasks Client instance.
142
+ #
143
+ # The configuration is set to the derived mode, meaning that values can be changed,
144
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
145
+ # should be made on {Client.configure}.
146
+ #
147
+ # See {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client::Configuration}
148
+ # for a description of the configuration fields.
149
+ #
150
+ # @yield [config] Configure the Client client.
151
+ # @yieldparam config [Client::Configuration]
152
+ #
153
+ # @return [Client::Configuration]
154
+ #
155
+ def configure
156
+ yield @config if block_given?
157
+ @config
158
+ end
159
+
160
+ ##
161
+ # Create a new CloudTasks REST client object.
162
+ #
163
+ # @example
164
+ #
165
+ # # Create a client using the default configuration
166
+ # client = ::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client.new
167
+ #
168
+ # # Create a client using a custom configuration
169
+ # client = ::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client.new do |config|
170
+ # config.timeout = 10.0
171
+ # end
172
+ #
173
+ # @yield [config] Configure the CloudTasks client.
174
+ # @yieldparam config [Client::Configuration]
175
+ #
176
+ def initialize
177
+ # Create the configuration object
178
+ @config = Configuration.new Client.configure
179
+
180
+ # Yield the configuration if needed
181
+ yield @config if block_given?
182
+
183
+ # Create credentials
184
+ credentials = @config.credentials
185
+ # Use self-signed JWT if the endpoint is unchanged from default,
186
+ # but only if the default endpoint does not have a region prefix.
187
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
188
+ !@config.endpoint.split(".").first.include?("-")
189
+ credentials ||= Credentials.default scope: @config.scope,
190
+ enable_self_signed_jwt: enable_self_signed_jwt
191
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
192
+ credentials = Credentials.new credentials, scope: @config.scope
193
+ end
194
+
195
+ @quota_project_id = @config.quota_project
196
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
197
+
198
+ @cloud_tasks_stub = ::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
199
+ end
200
+
201
+ # Service calls
202
+
203
+ ##
204
+ # Lists queues.
205
+ #
206
+ # Queues are returned in lexicographical order.
207
+ #
208
+ # @overload list_queues(request, options = nil)
209
+ # Pass arguments to `list_queues` via a request object, either of type
210
+ # {::Google::Cloud::Tasks::V2beta2::ListQueuesRequest} or an equivalent Hash.
211
+ #
212
+ # @param request [::Google::Cloud::Tasks::V2beta2::ListQueuesRequest, ::Hash]
213
+ # A request object representing the call parameters. Required. To specify no
214
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
215
+ # @param options [::Gapic::CallOptions, ::Hash]
216
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
217
+ #
218
+ # @overload list_queues(parent: nil, filter: nil, page_size: nil, page_token: nil, read_mask: nil)
219
+ # Pass arguments to `list_queues` via keyword arguments. Note that at
220
+ # least one keyword argument is required. To specify no parameters, or to keep all
221
+ # the default parameter values, pass an empty Hash as a request object (see above).
222
+ #
223
+ # @param parent [::String]
224
+ # Required. The location name.
225
+ # For example: `projects/PROJECT_ID/locations/LOCATION_ID`
226
+ # @param filter [::String]
227
+ # `filter` can be used to specify a subset of queues. Any {::Google::Cloud::Tasks::V2beta2::Queue Queue}
228
+ # field can be used as a filter and several operators as supported.
229
+ # For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as
230
+ # described in
231
+ # [Stackdriver's Advanced Logs
232
+ # Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
233
+ #
234
+ # Sample filter "app_engine_http_target: *".
235
+ #
236
+ # Note that using filters might cause fewer queues than the
237
+ # requested_page size to be returned.
238
+ # @param page_size [::Integer]
239
+ # Requested page size.
240
+ #
241
+ # The maximum page size is 9800. If unspecified, the page size will
242
+ # be the maximum. Fewer queues than requested might be returned,
243
+ # even if more queues exist; use the
244
+ # {::Google::Cloud::Tasks::V2beta2::ListQueuesResponse#next_page_token next_page_token} in the
245
+ # response to determine if more queues exist.
246
+ # @param page_token [::String]
247
+ # A token identifying the page of results to return.
248
+ #
249
+ # To request the first page results, page_token must be empty. To
250
+ # request the next page of results, page_token must be the value of
251
+ # {::Google::Cloud::Tasks::V2beta2::ListQueuesResponse#next_page_token next_page_token} returned
252
+ # from the previous call to {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#list_queues ListQueues}
253
+ # method. It is an error to switch the value of the
254
+ # {::Google::Cloud::Tasks::V2beta2::ListQueuesRequest#filter filter} while iterating through pages.
255
+ # @param read_mask [::Google::Protobuf::FieldMask, ::Hash]
256
+ # Optional. Read mask is used for a more granular control over what the API returns.
257
+ # If the mask is not present all fields will be returned except
258
+ # [Queue.stats]. [Queue.stats] will be returned only if it was explicitly
259
+ # specified in the mask.
260
+ # @yield [result, operation] Access the result along with the TransportOperation object
261
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Tasks::V2beta2::Queue>]
262
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
263
+ #
264
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Tasks::V2beta2::Queue>]
265
+ #
266
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
267
+ def list_queues request, options = nil
268
+ raise ::ArgumentError, "request must be provided" if request.nil?
269
+
270
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::ListQueuesRequest
271
+
272
+ # Converts hash and nil to an options object
273
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
274
+
275
+ # Customize the options with defaults
276
+ call_metadata = @config.rpcs.list_queues.metadata.to_h
277
+
278
+ # Set x-goog-api-client and x-goog-user-project headers
279
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
280
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
281
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
282
+ transports_version_send: [:rest]
283
+
284
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
285
+
286
+ options.apply_defaults timeout: @config.rpcs.list_queues.timeout,
287
+ metadata: call_metadata,
288
+ retry_policy: @config.rpcs.list_queues.retry_policy
289
+
290
+ options.apply_defaults timeout: @config.timeout,
291
+ metadata: @config.metadata,
292
+ retry_policy: @config.retry_policy
293
+
294
+ @cloud_tasks_stub.list_queues request, options do |result, operation|
295
+ result = ::Gapic::Rest::PagedEnumerable.new @cloud_tasks_stub, :list_queues, "queues", request, result, options
296
+ yield result, operation if block_given?
297
+ return result
298
+ end
299
+ rescue ::Gapic::Rest::Error => e
300
+ raise ::Google::Cloud::Error.from_error(e)
301
+ end
302
+
303
+ ##
304
+ # Gets a queue.
305
+ #
306
+ # @overload get_queue(request, options = nil)
307
+ # Pass arguments to `get_queue` via a request object, either of type
308
+ # {::Google::Cloud::Tasks::V2beta2::GetQueueRequest} or an equivalent Hash.
309
+ #
310
+ # @param request [::Google::Cloud::Tasks::V2beta2::GetQueueRequest, ::Hash]
311
+ # A request object representing the call parameters. Required. To specify no
312
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
313
+ # @param options [::Gapic::CallOptions, ::Hash]
314
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
315
+ #
316
+ # @overload get_queue(name: nil, read_mask: nil)
317
+ # Pass arguments to `get_queue` via keyword arguments. Note that at
318
+ # least one keyword argument is required. To specify no parameters, or to keep all
319
+ # the default parameter values, pass an empty Hash as a request object (see above).
320
+ #
321
+ # @param name [::String]
322
+ # Required. The resource name of the queue. For example:
323
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
324
+ # @param read_mask [::Google::Protobuf::FieldMask, ::Hash]
325
+ # Optional. Read mask is used for a more granular control over what the API returns.
326
+ # If the mask is not present all fields will be returned except
327
+ # [Queue.stats]. [Queue.stats] will be returned only if it was explicitly
328
+ # specified in the mask.
329
+ # @yield [result, operation] Access the result along with the TransportOperation object
330
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Queue]
331
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
332
+ #
333
+ # @return [::Google::Cloud::Tasks::V2beta2::Queue]
334
+ #
335
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
336
+ def get_queue request, options = nil
337
+ raise ::ArgumentError, "request must be provided" if request.nil?
338
+
339
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::GetQueueRequest
340
+
341
+ # Converts hash and nil to an options object
342
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
343
+
344
+ # Customize the options with defaults
345
+ call_metadata = @config.rpcs.get_queue.metadata.to_h
346
+
347
+ # Set x-goog-api-client and x-goog-user-project headers
348
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
349
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
350
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
351
+ transports_version_send: [:rest]
352
+
353
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
354
+
355
+ options.apply_defaults timeout: @config.rpcs.get_queue.timeout,
356
+ metadata: call_metadata,
357
+ retry_policy: @config.rpcs.get_queue.retry_policy
358
+
359
+ options.apply_defaults timeout: @config.timeout,
360
+ metadata: @config.metadata,
361
+ retry_policy: @config.retry_policy
362
+
363
+ @cloud_tasks_stub.get_queue request, options do |result, operation|
364
+ yield result, operation if block_given?
365
+ return result
366
+ end
367
+ rescue ::Gapic::Rest::Error => e
368
+ raise ::Google::Cloud::Error.from_error(e)
369
+ end
370
+
371
+ ##
372
+ # Creates a queue.
373
+ #
374
+ # Queues created with this method allow tasks to live for a maximum of 31
375
+ # days. After a task is 31 days old, the task will be deleted regardless of whether
376
+ # it was dispatched or not.
377
+ #
378
+ # WARNING: Using this method may have unintended side effects if you are
379
+ # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
380
+ # Read
381
+ # [Overview of Queue Management and
382
+ # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
383
+ # this method.
384
+ #
385
+ # @overload create_queue(request, options = nil)
386
+ # Pass arguments to `create_queue` via a request object, either of type
387
+ # {::Google::Cloud::Tasks::V2beta2::CreateQueueRequest} or an equivalent Hash.
388
+ #
389
+ # @param request [::Google::Cloud::Tasks::V2beta2::CreateQueueRequest, ::Hash]
390
+ # A request object representing the call parameters. Required. To specify no
391
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
392
+ # @param options [::Gapic::CallOptions, ::Hash]
393
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
394
+ #
395
+ # @overload create_queue(parent: nil, queue: nil)
396
+ # Pass arguments to `create_queue` via keyword arguments. Note that at
397
+ # least one keyword argument is required. To specify no parameters, or to keep all
398
+ # the default parameter values, pass an empty Hash as a request object (see above).
399
+ #
400
+ # @param parent [::String]
401
+ # Required. The location name in which the queue will be created.
402
+ # For example: `projects/PROJECT_ID/locations/LOCATION_ID`
403
+ #
404
+ # The list of allowed locations can be obtained by calling Cloud
405
+ # Tasks' implementation of
406
+ # [ListLocations][google.cloud.location.Locations.ListLocations].
407
+ # @param queue [::Google::Cloud::Tasks::V2beta2::Queue, ::Hash]
408
+ # Required. The queue to create.
409
+ #
410
+ # [Queue's name][google.cloud.tasks.v2beta2.Queue.name] cannot be the same as an existing queue.
411
+ # @yield [result, operation] Access the result along with the TransportOperation object
412
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Queue]
413
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
414
+ #
415
+ # @return [::Google::Cloud::Tasks::V2beta2::Queue]
416
+ #
417
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
418
+ def create_queue request, options = nil
419
+ raise ::ArgumentError, "request must be provided" if request.nil?
420
+
421
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::CreateQueueRequest
422
+
423
+ # Converts hash and nil to an options object
424
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
425
+
426
+ # Customize the options with defaults
427
+ call_metadata = @config.rpcs.create_queue.metadata.to_h
428
+
429
+ # Set x-goog-api-client and x-goog-user-project headers
430
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
431
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
432
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
433
+ transports_version_send: [:rest]
434
+
435
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
436
+
437
+ options.apply_defaults timeout: @config.rpcs.create_queue.timeout,
438
+ metadata: call_metadata,
439
+ retry_policy: @config.rpcs.create_queue.retry_policy
440
+
441
+ options.apply_defaults timeout: @config.timeout,
442
+ metadata: @config.metadata,
443
+ retry_policy: @config.retry_policy
444
+
445
+ @cloud_tasks_stub.create_queue request, options do |result, operation|
446
+ yield result, operation if block_given?
447
+ return result
448
+ end
449
+ rescue ::Gapic::Rest::Error => e
450
+ raise ::Google::Cloud::Error.from_error(e)
451
+ end
452
+
453
+ ##
454
+ # Updates a queue.
455
+ #
456
+ # This method creates the queue if it does not exist and updates
457
+ # the queue if it does exist.
458
+ #
459
+ # Queues created with this method allow tasks to live for a maximum of 31
460
+ # days. After a task is 31 days old, the task will be deleted regardless of whether
461
+ # it was dispatched or not.
462
+ #
463
+ # WARNING: Using this method may have unintended side effects if you are
464
+ # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
465
+ # Read
466
+ # [Overview of Queue Management and
467
+ # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
468
+ # this method.
469
+ #
470
+ # @overload update_queue(request, options = nil)
471
+ # Pass arguments to `update_queue` via a request object, either of type
472
+ # {::Google::Cloud::Tasks::V2beta2::UpdateQueueRequest} or an equivalent Hash.
473
+ #
474
+ # @param request [::Google::Cloud::Tasks::V2beta2::UpdateQueueRequest, ::Hash]
475
+ # A request object representing the call parameters. Required. To specify no
476
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
477
+ # @param options [::Gapic::CallOptions, ::Hash]
478
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
479
+ #
480
+ # @overload update_queue(queue: nil, update_mask: nil)
481
+ # Pass arguments to `update_queue` via keyword arguments. Note that at
482
+ # least one keyword argument is required. To specify no parameters, or to keep all
483
+ # the default parameter values, pass an empty Hash as a request object (see above).
484
+ #
485
+ # @param queue [::Google::Cloud::Tasks::V2beta2::Queue, ::Hash]
486
+ # Required. The queue to create or update.
487
+ #
488
+ # The queue's {::Google::Cloud::Tasks::V2beta2::Queue#name name} must be specified.
489
+ #
490
+ # Output only fields cannot be modified using UpdateQueue.
491
+ # Any value specified for an output only field will be ignored.
492
+ # The queue's {::Google::Cloud::Tasks::V2beta2::Queue#name name} cannot be changed.
493
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
494
+ # A mask used to specify which fields of the queue are being updated.
495
+ #
496
+ # If empty, then all fields will be updated.
497
+ # @yield [result, operation] Access the result along with the TransportOperation object
498
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Queue]
499
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
500
+ #
501
+ # @return [::Google::Cloud::Tasks::V2beta2::Queue]
502
+ #
503
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
504
+ def update_queue request, options = nil
505
+ raise ::ArgumentError, "request must be provided" if request.nil?
506
+
507
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::UpdateQueueRequest
508
+
509
+ # Converts hash and nil to an options object
510
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
511
+
512
+ # Customize the options with defaults
513
+ call_metadata = @config.rpcs.update_queue.metadata.to_h
514
+
515
+ # Set x-goog-api-client and x-goog-user-project headers
516
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
517
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
518
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
519
+ transports_version_send: [:rest]
520
+
521
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
522
+
523
+ options.apply_defaults timeout: @config.rpcs.update_queue.timeout,
524
+ metadata: call_metadata,
525
+ retry_policy: @config.rpcs.update_queue.retry_policy
526
+
527
+ options.apply_defaults timeout: @config.timeout,
528
+ metadata: @config.metadata,
529
+ retry_policy: @config.retry_policy
530
+
531
+ @cloud_tasks_stub.update_queue request, options do |result, operation|
532
+ yield result, operation if block_given?
533
+ return result
534
+ end
535
+ rescue ::Gapic::Rest::Error => e
536
+ raise ::Google::Cloud::Error.from_error(e)
537
+ end
538
+
539
+ ##
540
+ # Deletes a queue.
541
+ #
542
+ # This command will delete the queue even if it has tasks in it.
543
+ #
544
+ # Note: If you delete a queue, a queue with the same name can't be created
545
+ # for 7 days.
546
+ #
547
+ # WARNING: Using this method may have unintended side effects if you are
548
+ # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
549
+ # Read
550
+ # [Overview of Queue Management and
551
+ # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
552
+ # this method.
553
+ #
554
+ # @overload delete_queue(request, options = nil)
555
+ # Pass arguments to `delete_queue` via a request object, either of type
556
+ # {::Google::Cloud::Tasks::V2beta2::DeleteQueueRequest} or an equivalent Hash.
557
+ #
558
+ # @param request [::Google::Cloud::Tasks::V2beta2::DeleteQueueRequest, ::Hash]
559
+ # A request object representing the call parameters. Required. To specify no
560
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
561
+ # @param options [::Gapic::CallOptions, ::Hash]
562
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
563
+ #
564
+ # @overload delete_queue(name: nil)
565
+ # Pass arguments to `delete_queue` via keyword arguments. Note that at
566
+ # least one keyword argument is required. To specify no parameters, or to keep all
567
+ # the default parameter values, pass an empty Hash as a request object (see above).
568
+ #
569
+ # @param name [::String]
570
+ # Required. The queue name. For example:
571
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
572
+ # @yield [result, operation] Access the result along with the TransportOperation object
573
+ # @yieldparam result [::Google::Protobuf::Empty]
574
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
575
+ #
576
+ # @return [::Google::Protobuf::Empty]
577
+ #
578
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
579
+ def delete_queue request, options = nil
580
+ raise ::ArgumentError, "request must be provided" if request.nil?
581
+
582
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::DeleteQueueRequest
583
+
584
+ # Converts hash and nil to an options object
585
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
586
+
587
+ # Customize the options with defaults
588
+ call_metadata = @config.rpcs.delete_queue.metadata.to_h
589
+
590
+ # Set x-goog-api-client and x-goog-user-project headers
591
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
592
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
593
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
594
+ transports_version_send: [:rest]
595
+
596
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
597
+
598
+ options.apply_defaults timeout: @config.rpcs.delete_queue.timeout,
599
+ metadata: call_metadata,
600
+ retry_policy: @config.rpcs.delete_queue.retry_policy
601
+
602
+ options.apply_defaults timeout: @config.timeout,
603
+ metadata: @config.metadata,
604
+ retry_policy: @config.retry_policy
605
+
606
+ @cloud_tasks_stub.delete_queue request, options do |result, operation|
607
+ yield result, operation if block_given?
608
+ return result
609
+ end
610
+ rescue ::Gapic::Rest::Error => e
611
+ raise ::Google::Cloud::Error.from_error(e)
612
+ end
613
+
614
+ ##
615
+ # Purges a queue by deleting all of its tasks.
616
+ #
617
+ # All tasks created before this method is called are permanently deleted.
618
+ #
619
+ # Purge operations can take up to one minute to take effect. Tasks
620
+ # might be dispatched before the purge takes effect. A purge is irreversible.
621
+ #
622
+ # @overload purge_queue(request, options = nil)
623
+ # Pass arguments to `purge_queue` via a request object, either of type
624
+ # {::Google::Cloud::Tasks::V2beta2::PurgeQueueRequest} or an equivalent Hash.
625
+ #
626
+ # @param request [::Google::Cloud::Tasks::V2beta2::PurgeQueueRequest, ::Hash]
627
+ # A request object representing the call parameters. Required. To specify no
628
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
629
+ # @param options [::Gapic::CallOptions, ::Hash]
630
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
631
+ #
632
+ # @overload purge_queue(name: nil)
633
+ # Pass arguments to `purge_queue` via keyword arguments. Note that at
634
+ # least one keyword argument is required. To specify no parameters, or to keep all
635
+ # the default parameter values, pass an empty Hash as a request object (see above).
636
+ #
637
+ # @param name [::String]
638
+ # Required. The queue name. For example:
639
+ # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
640
+ # @yield [result, operation] Access the result along with the TransportOperation object
641
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Queue]
642
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
643
+ #
644
+ # @return [::Google::Cloud::Tasks::V2beta2::Queue]
645
+ #
646
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
647
+ def purge_queue request, options = nil
648
+ raise ::ArgumentError, "request must be provided" if request.nil?
649
+
650
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::PurgeQueueRequest
651
+
652
+ # Converts hash and nil to an options object
653
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
654
+
655
+ # Customize the options with defaults
656
+ call_metadata = @config.rpcs.purge_queue.metadata.to_h
657
+
658
+ # Set x-goog-api-client and x-goog-user-project headers
659
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
660
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
661
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
662
+ transports_version_send: [:rest]
663
+
664
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
665
+
666
+ options.apply_defaults timeout: @config.rpcs.purge_queue.timeout,
667
+ metadata: call_metadata,
668
+ retry_policy: @config.rpcs.purge_queue.retry_policy
669
+
670
+ options.apply_defaults timeout: @config.timeout,
671
+ metadata: @config.metadata,
672
+ retry_policy: @config.retry_policy
673
+
674
+ @cloud_tasks_stub.purge_queue request, options do |result, operation|
675
+ yield result, operation if block_given?
676
+ return result
677
+ end
678
+ rescue ::Gapic::Rest::Error => e
679
+ raise ::Google::Cloud::Error.from_error(e)
680
+ end
681
+
682
+ ##
683
+ # Pauses the queue.
684
+ #
685
+ # If a queue is paused then the system will stop dispatching tasks
686
+ # until the queue is resumed via
687
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#resume_queue ResumeQueue}. Tasks can still be added
688
+ # when the queue is paused. A queue is paused if its
689
+ # {::Google::Cloud::Tasks::V2beta2::Queue#state state} is {::Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
690
+ #
691
+ # @overload pause_queue(request, options = nil)
692
+ # Pass arguments to `pause_queue` via a request object, either of type
693
+ # {::Google::Cloud::Tasks::V2beta2::PauseQueueRequest} or an equivalent Hash.
694
+ #
695
+ # @param request [::Google::Cloud::Tasks::V2beta2::PauseQueueRequest, ::Hash]
696
+ # A request object representing the call parameters. Required. To specify no
697
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
698
+ # @param options [::Gapic::CallOptions, ::Hash]
699
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
700
+ #
701
+ # @overload pause_queue(name: nil)
702
+ # Pass arguments to `pause_queue` via keyword arguments. Note that at
703
+ # least one keyword argument is required. To specify no parameters, or to keep all
704
+ # the default parameter values, pass an empty Hash as a request object (see above).
705
+ #
706
+ # @param name [::String]
707
+ # Required. The queue name. For example:
708
+ # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
709
+ # @yield [result, operation] Access the result along with the TransportOperation object
710
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Queue]
711
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
712
+ #
713
+ # @return [::Google::Cloud::Tasks::V2beta2::Queue]
714
+ #
715
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
716
+ def pause_queue request, options = nil
717
+ raise ::ArgumentError, "request must be provided" if request.nil?
718
+
719
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::PauseQueueRequest
720
+
721
+ # Converts hash and nil to an options object
722
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
723
+
724
+ # Customize the options with defaults
725
+ call_metadata = @config.rpcs.pause_queue.metadata.to_h
726
+
727
+ # Set x-goog-api-client and x-goog-user-project headers
728
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
729
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
730
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
731
+ transports_version_send: [:rest]
732
+
733
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
734
+
735
+ options.apply_defaults timeout: @config.rpcs.pause_queue.timeout,
736
+ metadata: call_metadata,
737
+ retry_policy: @config.rpcs.pause_queue.retry_policy
738
+
739
+ options.apply_defaults timeout: @config.timeout,
740
+ metadata: @config.metadata,
741
+ retry_policy: @config.retry_policy
742
+
743
+ @cloud_tasks_stub.pause_queue request, options do |result, operation|
744
+ yield result, operation if block_given?
745
+ return result
746
+ end
747
+ rescue ::Gapic::Rest::Error => e
748
+ raise ::Google::Cloud::Error.from_error(e)
749
+ end
750
+
751
+ ##
752
+ # Resume a queue.
753
+ #
754
+ # This method resumes a queue after it has been
755
+ # {::Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED} or
756
+ # {::Google::Cloud::Tasks::V2beta2::Queue::State::DISABLED DISABLED}. The state of a queue is stored
757
+ # in the queue's {::Google::Cloud::Tasks::V2beta2::Queue#state state}; after calling this method it
758
+ # will be set to {::Google::Cloud::Tasks::V2beta2::Queue::State::RUNNING RUNNING}.
759
+ #
760
+ # WARNING: Resuming many high-QPS queues at the same time can
761
+ # lead to target overloading. If you are resuming high-QPS
762
+ # queues, follow the 500/50/5 pattern described in
763
+ # [Managing Cloud Tasks Scaling
764
+ # Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
765
+ #
766
+ # @overload resume_queue(request, options = nil)
767
+ # Pass arguments to `resume_queue` via a request object, either of type
768
+ # {::Google::Cloud::Tasks::V2beta2::ResumeQueueRequest} or an equivalent Hash.
769
+ #
770
+ # @param request [::Google::Cloud::Tasks::V2beta2::ResumeQueueRequest, ::Hash]
771
+ # A request object representing the call parameters. Required. To specify no
772
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
773
+ # @param options [::Gapic::CallOptions, ::Hash]
774
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
775
+ #
776
+ # @overload resume_queue(name: nil)
777
+ # Pass arguments to `resume_queue` via keyword arguments. Note that at
778
+ # least one keyword argument is required. To specify no parameters, or to keep all
779
+ # the default parameter values, pass an empty Hash as a request object (see above).
780
+ #
781
+ # @param name [::String]
782
+ # Required. The queue name. For example:
783
+ # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
784
+ # @yield [result, operation] Access the result along with the TransportOperation object
785
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Queue]
786
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
787
+ #
788
+ # @return [::Google::Cloud::Tasks::V2beta2::Queue]
789
+ #
790
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
791
+ def resume_queue request, options = nil
792
+ raise ::ArgumentError, "request must be provided" if request.nil?
793
+
794
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::ResumeQueueRequest
795
+
796
+ # Converts hash and nil to an options object
797
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
798
+
799
+ # Customize the options with defaults
800
+ call_metadata = @config.rpcs.resume_queue.metadata.to_h
801
+
802
+ # Set x-goog-api-client and x-goog-user-project headers
803
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
804
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
805
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
806
+ transports_version_send: [:rest]
807
+
808
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
809
+
810
+ options.apply_defaults timeout: @config.rpcs.resume_queue.timeout,
811
+ metadata: call_metadata,
812
+ retry_policy: @config.rpcs.resume_queue.retry_policy
813
+
814
+ options.apply_defaults timeout: @config.timeout,
815
+ metadata: @config.metadata,
816
+ retry_policy: @config.retry_policy
817
+
818
+ @cloud_tasks_stub.resume_queue request, options do |result, operation|
819
+ yield result, operation if block_given?
820
+ return result
821
+ end
822
+ rescue ::Gapic::Rest::Error => e
823
+ raise ::Google::Cloud::Error.from_error(e)
824
+ end
825
+
826
+ ##
827
+ # Gets the access control policy for a {::Google::Cloud::Tasks::V2beta2::Queue Queue}.
828
+ # Returns an empty policy if the resource exists and does not have a policy
829
+ # set.
830
+ #
831
+ # Authorization requires the following
832
+ # [Google IAM](https://cloud.google.com/iam) permission on the specified
833
+ # resource parent:
834
+ #
835
+ # * `cloudtasks.queues.getIamPolicy`
836
+ #
837
+ # @overload get_iam_policy(request, options = nil)
838
+ # Pass arguments to `get_iam_policy` via a request object, either of type
839
+ # {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash.
840
+ #
841
+ # @param request [::Google::Iam::V1::GetIamPolicyRequest, ::Hash]
842
+ # A request object representing the call parameters. Required. To specify no
843
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
844
+ # @param options [::Gapic::CallOptions, ::Hash]
845
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
846
+ #
847
+ # @overload get_iam_policy(resource: nil, options: nil)
848
+ # Pass arguments to `get_iam_policy` via keyword arguments. Note that at
849
+ # least one keyword argument is required. To specify no parameters, or to keep all
850
+ # the default parameter values, pass an empty Hash as a request object (see above).
851
+ #
852
+ # @param resource [::String]
853
+ # REQUIRED: The resource for which the policy is being requested.
854
+ # See the operation documentation for the appropriate value for this field.
855
+ # @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash]
856
+ # OPTIONAL: A `GetPolicyOptions` object for specifying options to
857
+ # `GetIamPolicy`.
858
+ # @yield [result, operation] Access the result along with the TransportOperation object
859
+ # @yieldparam result [::Google::Iam::V1::Policy]
860
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
861
+ #
862
+ # @return [::Google::Iam::V1::Policy]
863
+ #
864
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
865
+ def get_iam_policy request, options = nil
866
+ raise ::ArgumentError, "request must be provided" if request.nil?
867
+
868
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest
869
+
870
+ # Converts hash and nil to an options object
871
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
872
+
873
+ # Customize the options with defaults
874
+ call_metadata = @config.rpcs.get_iam_policy.metadata.to_h
875
+
876
+ # Set x-goog-api-client and x-goog-user-project headers
877
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
878
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
879
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
880
+ transports_version_send: [:rest]
881
+
882
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
883
+
884
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
885
+ metadata: call_metadata,
886
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
887
+
888
+ options.apply_defaults timeout: @config.timeout,
889
+ metadata: @config.metadata,
890
+ retry_policy: @config.retry_policy
891
+
892
+ @cloud_tasks_stub.get_iam_policy request, options do |result, operation|
893
+ yield result, operation if block_given?
894
+ return result
895
+ end
896
+ rescue ::Gapic::Rest::Error => e
897
+ raise ::Google::Cloud::Error.from_error(e)
898
+ end
899
+
900
+ ##
901
+ # Sets the access control policy for a {::Google::Cloud::Tasks::V2beta2::Queue Queue}. Replaces any existing
902
+ # policy.
903
+ #
904
+ # Note: The Cloud Console does not check queue-level IAM permissions yet.
905
+ # Project-level permissions are required to use the Cloud Console.
906
+ #
907
+ # Authorization requires the following
908
+ # [Google IAM](https://cloud.google.com/iam) permission on the specified
909
+ # resource parent:
910
+ #
911
+ # * `cloudtasks.queues.setIamPolicy`
912
+ #
913
+ # @overload set_iam_policy(request, options = nil)
914
+ # Pass arguments to `set_iam_policy` via a request object, either of type
915
+ # {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash.
916
+ #
917
+ # @param request [::Google::Iam::V1::SetIamPolicyRequest, ::Hash]
918
+ # A request object representing the call parameters. Required. To specify no
919
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
920
+ # @param options [::Gapic::CallOptions, ::Hash]
921
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
922
+ #
923
+ # @overload set_iam_policy(resource: nil, policy: nil, update_mask: nil)
924
+ # Pass arguments to `set_iam_policy` via keyword arguments. Note that at
925
+ # least one keyword argument is required. To specify no parameters, or to keep all
926
+ # the default parameter values, pass an empty Hash as a request object (see above).
927
+ #
928
+ # @param resource [::String]
929
+ # REQUIRED: The resource for which the policy is being specified.
930
+ # See the operation documentation for the appropriate value for this field.
931
+ # @param policy [::Google::Iam::V1::Policy, ::Hash]
932
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
933
+ # the policy is limited to a few 10s of KB. An empty policy is a
934
+ # valid policy but certain Cloud Platform services (such as Projects)
935
+ # might reject them.
936
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
937
+ # OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
938
+ # the fields in the mask will be modified. If no mask is provided, the
939
+ # following default mask is used:
940
+ #
941
+ # `paths: "bindings, etag"`
942
+ # @yield [result, operation] Access the result along with the TransportOperation object
943
+ # @yieldparam result [::Google::Iam::V1::Policy]
944
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
945
+ #
946
+ # @return [::Google::Iam::V1::Policy]
947
+ #
948
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
949
+ def set_iam_policy request, options = nil
950
+ raise ::ArgumentError, "request must be provided" if request.nil?
951
+
952
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest
953
+
954
+ # Converts hash and nil to an options object
955
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
956
+
957
+ # Customize the options with defaults
958
+ call_metadata = @config.rpcs.set_iam_policy.metadata.to_h
959
+
960
+ # Set x-goog-api-client and x-goog-user-project headers
961
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
962
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
963
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
964
+ transports_version_send: [:rest]
965
+
966
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
967
+
968
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
969
+ metadata: call_metadata,
970
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
971
+
972
+ options.apply_defaults timeout: @config.timeout,
973
+ metadata: @config.metadata,
974
+ retry_policy: @config.retry_policy
975
+
976
+ @cloud_tasks_stub.set_iam_policy request, options do |result, operation|
977
+ yield result, operation if block_given?
978
+ return result
979
+ end
980
+ rescue ::Gapic::Rest::Error => e
981
+ raise ::Google::Cloud::Error.from_error(e)
982
+ end
983
+
984
+ ##
985
+ # Returns permissions that a caller has on a {::Google::Cloud::Tasks::V2beta2::Queue Queue}.
986
+ # If the resource does not exist, this will return an empty set of
987
+ # permissions, not a [NOT_FOUND][google.rpc.Code.NOT_FOUND] error.
988
+ #
989
+ # Note: This operation is designed to be used for building permission-aware
990
+ # UIs and command-line tools, not for authorization checking. This operation
991
+ # may "fail open" without warning.
992
+ #
993
+ # @overload test_iam_permissions(request, options = nil)
994
+ # Pass arguments to `test_iam_permissions` via a request object, either of type
995
+ # {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash.
996
+ #
997
+ # @param request [::Google::Iam::V1::TestIamPermissionsRequest, ::Hash]
998
+ # A request object representing the call parameters. Required. To specify no
999
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1000
+ # @param options [::Gapic::CallOptions, ::Hash]
1001
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1002
+ #
1003
+ # @overload test_iam_permissions(resource: nil, permissions: nil)
1004
+ # Pass arguments to `test_iam_permissions` via keyword arguments. Note that at
1005
+ # least one keyword argument is required. To specify no parameters, or to keep all
1006
+ # the default parameter values, pass an empty Hash as a request object (see above).
1007
+ #
1008
+ # @param resource [::String]
1009
+ # REQUIRED: The resource for which the policy detail is being requested.
1010
+ # See the operation documentation for the appropriate value for this field.
1011
+ # @param permissions [::Array<::String>]
1012
+ # The set of permissions to check for the `resource`. Permissions with
1013
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
1014
+ # information see
1015
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1016
+ # @yield [result, operation] Access the result along with the TransportOperation object
1017
+ # @yieldparam result [::Google::Iam::V1::TestIamPermissionsResponse]
1018
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1019
+ #
1020
+ # @return [::Google::Iam::V1::TestIamPermissionsResponse]
1021
+ #
1022
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1023
+ def test_iam_permissions request, options = nil
1024
+ raise ::ArgumentError, "request must be provided" if request.nil?
1025
+
1026
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest
1027
+
1028
+ # Converts hash and nil to an options object
1029
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1030
+
1031
+ # Customize the options with defaults
1032
+ call_metadata = @config.rpcs.test_iam_permissions.metadata.to_h
1033
+
1034
+ # Set x-goog-api-client and x-goog-user-project headers
1035
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1036
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1037
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1038
+ transports_version_send: [:rest]
1039
+
1040
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1041
+
1042
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
1043
+ metadata: call_metadata,
1044
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
1045
+
1046
+ options.apply_defaults timeout: @config.timeout,
1047
+ metadata: @config.metadata,
1048
+ retry_policy: @config.retry_policy
1049
+
1050
+ @cloud_tasks_stub.test_iam_permissions request, options do |result, operation|
1051
+ yield result, operation if block_given?
1052
+ return result
1053
+ end
1054
+ rescue ::Gapic::Rest::Error => e
1055
+ raise ::Google::Cloud::Error.from_error(e)
1056
+ end
1057
+
1058
+ ##
1059
+ # Lists the tasks in a queue.
1060
+ #
1061
+ # By default, only the {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC} view is retrieved
1062
+ # due to performance considerations;
1063
+ # {::Google::Cloud::Tasks::V2beta2::ListTasksRequest#response_view response_view} controls the
1064
+ # subset of information which is returned.
1065
+ #
1066
+ # The tasks may be returned in any order. The ordering may change at any
1067
+ # time.
1068
+ #
1069
+ # @overload list_tasks(request, options = nil)
1070
+ # Pass arguments to `list_tasks` via a request object, either of type
1071
+ # {::Google::Cloud::Tasks::V2beta2::ListTasksRequest} or an equivalent Hash.
1072
+ #
1073
+ # @param request [::Google::Cloud::Tasks::V2beta2::ListTasksRequest, ::Hash]
1074
+ # A request object representing the call parameters. Required. To specify no
1075
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1076
+ # @param options [::Gapic::CallOptions, ::Hash]
1077
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1078
+ #
1079
+ # @overload list_tasks(parent: nil, response_view: nil, page_size: nil, page_token: nil)
1080
+ # Pass arguments to `list_tasks` via keyword arguments. Note that at
1081
+ # least one keyword argument is required. To specify no parameters, or to keep all
1082
+ # the default parameter values, pass an empty Hash as a request object (see above).
1083
+ #
1084
+ # @param parent [::String]
1085
+ # Required. The queue name. For example:
1086
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1087
+ # @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View]
1088
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be
1089
+ # returned.
1090
+ #
1091
+ # By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1092
+ # information is retrieved by default because some data, such as
1093
+ # payloads, might be desirable to return only when needed because
1094
+ # of its large size or because of the sensitivity of data that it
1095
+ # contains.
1096
+ #
1097
+ # Authorization for {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1098
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1099
+ # permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
1100
+ # @param page_size [::Integer]
1101
+ # Maximum page size.
1102
+ #
1103
+ # Fewer tasks than requested might be returned, even if more tasks exist; use
1104
+ # {::Google::Cloud::Tasks::V2beta2::ListTasksResponse#next_page_token next_page_token} in the response to
1105
+ # determine if more tasks exist.
1106
+ #
1107
+ # The maximum page size is 1000. If unspecified, the page size will be the
1108
+ # maximum.
1109
+ # @param page_token [::String]
1110
+ # A token identifying the page of results to return.
1111
+ #
1112
+ # To request the first page results, page_token must be empty. To
1113
+ # request the next page of results, page_token must be the value of
1114
+ # {::Google::Cloud::Tasks::V2beta2::ListTasksResponse#next_page_token next_page_token} returned
1115
+ # from the previous call to {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#list_tasks ListTasks}
1116
+ # method.
1117
+ #
1118
+ # The page token is valid for only 2 hours.
1119
+ # @yield [result, operation] Access the result along with the TransportOperation object
1120
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Tasks::V2beta2::Task>]
1121
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1122
+ #
1123
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Tasks::V2beta2::Task>]
1124
+ #
1125
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1126
+ def list_tasks request, options = nil
1127
+ raise ::ArgumentError, "request must be provided" if request.nil?
1128
+
1129
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::ListTasksRequest
1130
+
1131
+ # Converts hash and nil to an options object
1132
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1133
+
1134
+ # Customize the options with defaults
1135
+ call_metadata = @config.rpcs.list_tasks.metadata.to_h
1136
+
1137
+ # Set x-goog-api-client and x-goog-user-project headers
1138
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1139
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1140
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1141
+ transports_version_send: [:rest]
1142
+
1143
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1144
+
1145
+ options.apply_defaults timeout: @config.rpcs.list_tasks.timeout,
1146
+ metadata: call_metadata,
1147
+ retry_policy: @config.rpcs.list_tasks.retry_policy
1148
+
1149
+ options.apply_defaults timeout: @config.timeout,
1150
+ metadata: @config.metadata,
1151
+ retry_policy: @config.retry_policy
1152
+
1153
+ @cloud_tasks_stub.list_tasks request, options do |result, operation|
1154
+ result = ::Gapic::Rest::PagedEnumerable.new @cloud_tasks_stub, :list_tasks, "tasks", request, result, options
1155
+ yield result, operation if block_given?
1156
+ return result
1157
+ end
1158
+ rescue ::Gapic::Rest::Error => e
1159
+ raise ::Google::Cloud::Error.from_error(e)
1160
+ end
1161
+
1162
+ ##
1163
+ # Gets a task.
1164
+ #
1165
+ # @overload get_task(request, options = nil)
1166
+ # Pass arguments to `get_task` via a request object, either of type
1167
+ # {::Google::Cloud::Tasks::V2beta2::GetTaskRequest} or an equivalent Hash.
1168
+ #
1169
+ # @param request [::Google::Cloud::Tasks::V2beta2::GetTaskRequest, ::Hash]
1170
+ # A request object representing the call parameters. Required. To specify no
1171
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1172
+ # @param options [::Gapic::CallOptions, ::Hash]
1173
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1174
+ #
1175
+ # @overload get_task(name: nil, response_view: nil)
1176
+ # Pass arguments to `get_task` via keyword arguments. Note that at
1177
+ # least one keyword argument is required. To specify no parameters, or to keep all
1178
+ # the default parameter values, pass an empty Hash as a request object (see above).
1179
+ #
1180
+ # @param name [::String]
1181
+ # Required. The task name. For example:
1182
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1183
+ # @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View]
1184
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be
1185
+ # returned.
1186
+ #
1187
+ # By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1188
+ # information is retrieved by default because some data, such as
1189
+ # payloads, might be desirable to return only when needed because
1190
+ # of its large size or because of the sensitivity of data that it
1191
+ # contains.
1192
+ #
1193
+ # Authorization for {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1194
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1195
+ # permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
1196
+ # @yield [result, operation] Access the result along with the TransportOperation object
1197
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Task]
1198
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1199
+ #
1200
+ # @return [::Google::Cloud::Tasks::V2beta2::Task]
1201
+ #
1202
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1203
+ def get_task request, options = nil
1204
+ raise ::ArgumentError, "request must be provided" if request.nil?
1205
+
1206
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::GetTaskRequest
1207
+
1208
+ # Converts hash and nil to an options object
1209
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1210
+
1211
+ # Customize the options with defaults
1212
+ call_metadata = @config.rpcs.get_task.metadata.to_h
1213
+
1214
+ # Set x-goog-api-client and x-goog-user-project headers
1215
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1216
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1217
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1218
+ transports_version_send: [:rest]
1219
+
1220
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1221
+
1222
+ options.apply_defaults timeout: @config.rpcs.get_task.timeout,
1223
+ metadata: call_metadata,
1224
+ retry_policy: @config.rpcs.get_task.retry_policy
1225
+
1226
+ options.apply_defaults timeout: @config.timeout,
1227
+ metadata: @config.metadata,
1228
+ retry_policy: @config.retry_policy
1229
+
1230
+ @cloud_tasks_stub.get_task request, options do |result, operation|
1231
+ yield result, operation if block_given?
1232
+ return result
1233
+ end
1234
+ rescue ::Gapic::Rest::Error => e
1235
+ raise ::Google::Cloud::Error.from_error(e)
1236
+ end
1237
+
1238
+ ##
1239
+ # Creates a task and adds it to a queue.
1240
+ #
1241
+ # Tasks cannot be updated after creation; there is no UpdateTask command.
1242
+ #
1243
+ # * For {::Google::Cloud::Tasks::V2beta2::AppEngineHttpTarget App Engine queues}, the maximum task size is
1244
+ # 100KB.
1245
+ # * For {::Google::Cloud::Tasks::V2beta2::PullTarget pull queues}, the maximum task size is 1MB.
1246
+ #
1247
+ # @overload create_task(request, options = nil)
1248
+ # Pass arguments to `create_task` via a request object, either of type
1249
+ # {::Google::Cloud::Tasks::V2beta2::CreateTaskRequest} or an equivalent Hash.
1250
+ #
1251
+ # @param request [::Google::Cloud::Tasks::V2beta2::CreateTaskRequest, ::Hash]
1252
+ # A request object representing the call parameters. Required. To specify no
1253
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1254
+ # @param options [::Gapic::CallOptions, ::Hash]
1255
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1256
+ #
1257
+ # @overload create_task(parent: nil, task: nil, response_view: nil)
1258
+ # Pass arguments to `create_task` via keyword arguments. Note that at
1259
+ # least one keyword argument is required. To specify no parameters, or to keep all
1260
+ # the default parameter values, pass an empty Hash as a request object (see above).
1261
+ #
1262
+ # @param parent [::String]
1263
+ # Required. The queue name. For example:
1264
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1265
+ #
1266
+ # The queue must already exist.
1267
+ # @param task [::Google::Cloud::Tasks::V2beta2::Task, ::Hash]
1268
+ # Required. The task to add.
1269
+ #
1270
+ # Task names have the following format:
1271
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`.
1272
+ # The user can optionally specify a task {::Google::Cloud::Tasks::V2beta2::Task#name name}. If a
1273
+ # name is not specified then the system will generate a random
1274
+ # unique task id, which will be set in the task returned in the
1275
+ # {::Google::Cloud::Tasks::V2beta2::Task#name response}.
1276
+ #
1277
+ # If {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} is not set or is in the
1278
+ # past then Cloud Tasks will set it to the current time.
1279
+ #
1280
+ # Task De-duplication:
1281
+ #
1282
+ # Explicitly specifying a task ID enables task de-duplication. If
1283
+ # a task's ID is identical to that of an existing task or a task
1284
+ # that was deleted or completed recently then the call will fail
1285
+ # with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS].
1286
+ # If the task's queue was created using Cloud Tasks, then another task with
1287
+ # the same name can't be created for ~1hour after the original task was
1288
+ # deleted or completed. If the task's queue was created using queue.yaml or
1289
+ # queue.xml, then another task with the same name can't be created
1290
+ # for ~9days after the original task was deleted or completed.
1291
+ #
1292
+ # Because there is an extra lookup cost to identify duplicate task
1293
+ # names, these {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#create_task CreateTask} calls have significantly
1294
+ # increased latency. Using hashed strings for the task id or for
1295
+ # the prefix of the task id is recommended. Choosing task ids that
1296
+ # are sequential or have sequential prefixes, for example using a
1297
+ # timestamp, causes an increase in latency and error rates in all
1298
+ # task commands. The infrastructure relies on an approximately
1299
+ # uniform distribution of task ids to store and serve tasks
1300
+ # efficiently.
1301
+ # @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View]
1302
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be
1303
+ # returned.
1304
+ #
1305
+ # By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1306
+ # information is retrieved by default because some data, such as
1307
+ # payloads, might be desirable to return only when needed because
1308
+ # of its large size or because of the sensitivity of data that it
1309
+ # contains.
1310
+ #
1311
+ # Authorization for {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1312
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1313
+ # permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
1314
+ # @yield [result, operation] Access the result along with the TransportOperation object
1315
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Task]
1316
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1317
+ #
1318
+ # @return [::Google::Cloud::Tasks::V2beta2::Task]
1319
+ #
1320
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1321
+ def create_task request, options = nil
1322
+ raise ::ArgumentError, "request must be provided" if request.nil?
1323
+
1324
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::CreateTaskRequest
1325
+
1326
+ # Converts hash and nil to an options object
1327
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1328
+
1329
+ # Customize the options with defaults
1330
+ call_metadata = @config.rpcs.create_task.metadata.to_h
1331
+
1332
+ # Set x-goog-api-client and x-goog-user-project headers
1333
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1334
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1335
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1336
+ transports_version_send: [:rest]
1337
+
1338
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1339
+
1340
+ options.apply_defaults timeout: @config.rpcs.create_task.timeout,
1341
+ metadata: call_metadata,
1342
+ retry_policy: @config.rpcs.create_task.retry_policy
1343
+
1344
+ options.apply_defaults timeout: @config.timeout,
1345
+ metadata: @config.metadata,
1346
+ retry_policy: @config.retry_policy
1347
+
1348
+ @cloud_tasks_stub.create_task request, options do |result, operation|
1349
+ yield result, operation if block_given?
1350
+ return result
1351
+ end
1352
+ rescue ::Gapic::Rest::Error => e
1353
+ raise ::Google::Cloud::Error.from_error(e)
1354
+ end
1355
+
1356
+ ##
1357
+ # Deletes a task.
1358
+ #
1359
+ # A task can be deleted if it is scheduled or dispatched. A task
1360
+ # cannot be deleted if it has completed successfully or permanently
1361
+ # failed.
1362
+ #
1363
+ # @overload delete_task(request, options = nil)
1364
+ # Pass arguments to `delete_task` via a request object, either of type
1365
+ # {::Google::Cloud::Tasks::V2beta2::DeleteTaskRequest} or an equivalent Hash.
1366
+ #
1367
+ # @param request [::Google::Cloud::Tasks::V2beta2::DeleteTaskRequest, ::Hash]
1368
+ # A request object representing the call parameters. Required. To specify no
1369
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1370
+ # @param options [::Gapic::CallOptions, ::Hash]
1371
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1372
+ #
1373
+ # @overload delete_task(name: nil)
1374
+ # Pass arguments to `delete_task` via keyword arguments. Note that at
1375
+ # least one keyword argument is required. To specify no parameters, or to keep all
1376
+ # the default parameter values, pass an empty Hash as a request object (see above).
1377
+ #
1378
+ # @param name [::String]
1379
+ # Required. The task name. For example:
1380
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1381
+ # @yield [result, operation] Access the result along with the TransportOperation object
1382
+ # @yieldparam result [::Google::Protobuf::Empty]
1383
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1384
+ #
1385
+ # @return [::Google::Protobuf::Empty]
1386
+ #
1387
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1388
+ def delete_task request, options = nil
1389
+ raise ::ArgumentError, "request must be provided" if request.nil?
1390
+
1391
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::DeleteTaskRequest
1392
+
1393
+ # Converts hash and nil to an options object
1394
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1395
+
1396
+ # Customize the options with defaults
1397
+ call_metadata = @config.rpcs.delete_task.metadata.to_h
1398
+
1399
+ # Set x-goog-api-client and x-goog-user-project headers
1400
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1401
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1402
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1403
+ transports_version_send: [:rest]
1404
+
1405
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1406
+
1407
+ options.apply_defaults timeout: @config.rpcs.delete_task.timeout,
1408
+ metadata: call_metadata,
1409
+ retry_policy: @config.rpcs.delete_task.retry_policy
1410
+
1411
+ options.apply_defaults timeout: @config.timeout,
1412
+ metadata: @config.metadata,
1413
+ retry_policy: @config.retry_policy
1414
+
1415
+ @cloud_tasks_stub.delete_task request, options do |result, operation|
1416
+ yield result, operation if block_given?
1417
+ return result
1418
+ end
1419
+ rescue ::Gapic::Rest::Error => e
1420
+ raise ::Google::Cloud::Error.from_error(e)
1421
+ end
1422
+
1423
+ ##
1424
+ # Leases tasks from a pull queue for
1425
+ # {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration}.
1426
+ #
1427
+ # This method is invoked by the worker to obtain a lease. The
1428
+ # worker must acknowledge the task via
1429
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#acknowledge_task AcknowledgeTask} after they have
1430
+ # performed the work associated with the task.
1431
+ #
1432
+ # The {::Google::Cloud::Tasks::V2beta2::PullMessage#payload payload} is intended to store data that
1433
+ # the worker needs to perform the work associated with the task. To
1434
+ # return the payloads in the {::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response}, set
1435
+ # {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#response_view response_view} to
1436
+ # {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL}.
1437
+ #
1438
+ # A maximum of 10 qps of {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks LeaseTasks}
1439
+ # requests are allowed per
1440
+ # queue. [RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED]
1441
+ # is returned when this limit is
1442
+ # exceeded. [RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED]
1443
+ # is also returned when
1444
+ # {::Google::Cloud::Tasks::V2beta2::RateLimits#max_tasks_dispatched_per_second max_tasks_dispatched_per_second}
1445
+ # is exceeded.
1446
+ #
1447
+ # @overload lease_tasks(request, options = nil)
1448
+ # Pass arguments to `lease_tasks` via a request object, either of type
1449
+ # {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest} or an equivalent Hash.
1450
+ #
1451
+ # @param request [::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest, ::Hash]
1452
+ # A request object representing the call parameters. Required. To specify no
1453
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1454
+ # @param options [::Gapic::CallOptions, ::Hash]
1455
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1456
+ #
1457
+ # @overload lease_tasks(parent: nil, max_tasks: nil, lease_duration: nil, response_view: nil, filter: nil)
1458
+ # Pass arguments to `lease_tasks` via keyword arguments. Note that at
1459
+ # least one keyword argument is required. To specify no parameters, or to keep all
1460
+ # the default parameter values, pass an empty Hash as a request object (see above).
1461
+ #
1462
+ # @param parent [::String]
1463
+ # Required. The queue name. For example:
1464
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1465
+ # @param max_tasks [::Integer]
1466
+ # The maximum number of tasks to lease.
1467
+ #
1468
+ # The system will make a best effort to return as close to as
1469
+ # `max_tasks` as possible.
1470
+ #
1471
+ # The largest that `max_tasks` can be is 1000.
1472
+ #
1473
+ # The maximum total size of a {::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse lease tasks response} is
1474
+ # 32 MB. If the sum of all task sizes requested reaches this limit,
1475
+ # fewer tasks than requested are returned.
1476
+ # @param lease_duration [::Google::Protobuf::Duration, ::Hash]
1477
+ # Required. The duration of the lease.
1478
+ #
1479
+ # Each task returned in the {::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response} will
1480
+ # have its {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} set to the current
1481
+ # time plus the `lease_duration`. The task is leased until its
1482
+ # {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}; thus, the task will not be
1483
+ # returned to another {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks LeaseTasks} call
1484
+ # before its {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}.
1485
+ #
1486
+ #
1487
+ # After the worker has successfully finished the work associated
1488
+ # with the task, the worker must call via
1489
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#acknowledge_task AcknowledgeTask} before the
1490
+ # {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}. Otherwise the task will be
1491
+ # returned to a later {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks LeaseTasks} call so
1492
+ # that another worker can retry it.
1493
+ #
1494
+ # The maximum lease duration is 1 week.
1495
+ # `lease_duration` will be truncated to the nearest second.
1496
+ # @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View]
1497
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be
1498
+ # returned.
1499
+ #
1500
+ # By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1501
+ # information is retrieved by default because some data, such as
1502
+ # payloads, might be desirable to return only when needed because
1503
+ # of its large size or because of the sensitivity of data that it
1504
+ # contains.
1505
+ #
1506
+ # Authorization for {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1507
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1508
+ # permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
1509
+ # @param filter [::String]
1510
+ # `filter` can be used to specify a subset of tasks to lease.
1511
+ #
1512
+ # When `filter` is set to `tag=<my-tag>` then the
1513
+ # {::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response} will contain only tasks whose
1514
+ # {::Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} is equal to `<my-tag>`. `<my-tag>` must be
1515
+ # less than 500 characters.
1516
+ #
1517
+ # When `filter` is set to `tag_function=oldest_tag()`, only tasks which have
1518
+ # the same tag as the task with the oldest
1519
+ # {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be returned.
1520
+ #
1521
+ # Grammar Syntax:
1522
+ #
1523
+ # * `filter = "tag=" tag | "tag_function=" function`
1524
+ #
1525
+ # * `tag = string`
1526
+ #
1527
+ # * `function = "oldest_tag()"`
1528
+ #
1529
+ # The `oldest_tag()` function returns tasks which have the same tag as the
1530
+ # oldest task (ordered by schedule time).
1531
+ #
1532
+ # SDK compatibility: Although the SDK allows tags to be either
1533
+ # string or
1534
+ # [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-),
1535
+ # only UTF-8 encoded tags can be used in Cloud Tasks. Tag which
1536
+ # aren't UTF-8 encoded can't be used in the
1537
+ # {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#filter filter} and the task's
1538
+ # {::Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} will be displayed as empty in Cloud Tasks.
1539
+ # @yield [result, operation] Access the result along with the TransportOperation object
1540
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse]
1541
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1542
+ #
1543
+ # @return [::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse]
1544
+ #
1545
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1546
+ def lease_tasks request, options = nil
1547
+ raise ::ArgumentError, "request must be provided" if request.nil?
1548
+
1549
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest
1550
+
1551
+ # Converts hash and nil to an options object
1552
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1553
+
1554
+ # Customize the options with defaults
1555
+ call_metadata = @config.rpcs.lease_tasks.metadata.to_h
1556
+
1557
+ # Set x-goog-api-client and x-goog-user-project headers
1558
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1559
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1560
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1561
+ transports_version_send: [:rest]
1562
+
1563
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1564
+
1565
+ options.apply_defaults timeout: @config.rpcs.lease_tasks.timeout,
1566
+ metadata: call_metadata,
1567
+ retry_policy: @config.rpcs.lease_tasks.retry_policy
1568
+
1569
+ options.apply_defaults timeout: @config.timeout,
1570
+ metadata: @config.metadata,
1571
+ retry_policy: @config.retry_policy
1572
+
1573
+ @cloud_tasks_stub.lease_tasks request, options do |result, operation|
1574
+ yield result, operation if block_given?
1575
+ return result
1576
+ end
1577
+ rescue ::Gapic::Rest::Error => e
1578
+ raise ::Google::Cloud::Error.from_error(e)
1579
+ end
1580
+
1581
+ ##
1582
+ # Acknowledges a pull task.
1583
+ #
1584
+ # The worker, that is, the entity that
1585
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks leased} this task must call this method
1586
+ # to indicate that the work associated with the task has finished.
1587
+ #
1588
+ # The worker must acknowledge a task within the
1589
+ # {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration} or the lease
1590
+ # will expire and the task will become available to be leased
1591
+ # again. After the task is acknowledged, it will not be returned
1592
+ # by a later {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks LeaseTasks},
1593
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#get_task GetTask}, or
1594
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#list_tasks ListTasks}.
1595
+ #
1596
+ # @overload acknowledge_task(request, options = nil)
1597
+ # Pass arguments to `acknowledge_task` via a request object, either of type
1598
+ # {::Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest} or an equivalent Hash.
1599
+ #
1600
+ # @param request [::Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest, ::Hash]
1601
+ # A request object representing the call parameters. Required. To specify no
1602
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1603
+ # @param options [::Gapic::CallOptions, ::Hash]
1604
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1605
+ #
1606
+ # @overload acknowledge_task(name: nil, schedule_time: nil)
1607
+ # Pass arguments to `acknowledge_task` via keyword arguments. Note that at
1608
+ # least one keyword argument is required. To specify no parameters, or to keep all
1609
+ # the default parameter values, pass an empty Hash as a request object (see above).
1610
+ #
1611
+ # @param name [::String]
1612
+ # Required. The task name. For example:
1613
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1614
+ # @param schedule_time [::Google::Protobuf::Timestamp, ::Hash]
1615
+ # Required. The task's current schedule time, available in the
1616
+ # {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
1617
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks LeaseTasks} response or
1618
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#renew_lease RenewLease} response. This restriction is
1619
+ # to ensure that your worker currently holds the lease.
1620
+ # @yield [result, operation] Access the result along with the TransportOperation object
1621
+ # @yieldparam result [::Google::Protobuf::Empty]
1622
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1623
+ #
1624
+ # @return [::Google::Protobuf::Empty]
1625
+ #
1626
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1627
+ def acknowledge_task request, options = nil
1628
+ raise ::ArgumentError, "request must be provided" if request.nil?
1629
+
1630
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest
1631
+
1632
+ # Converts hash and nil to an options object
1633
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1634
+
1635
+ # Customize the options with defaults
1636
+ call_metadata = @config.rpcs.acknowledge_task.metadata.to_h
1637
+
1638
+ # Set x-goog-api-client and x-goog-user-project headers
1639
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1640
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1641
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1642
+ transports_version_send: [:rest]
1643
+
1644
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1645
+
1646
+ options.apply_defaults timeout: @config.rpcs.acknowledge_task.timeout,
1647
+ metadata: call_metadata,
1648
+ retry_policy: @config.rpcs.acknowledge_task.retry_policy
1649
+
1650
+ options.apply_defaults timeout: @config.timeout,
1651
+ metadata: @config.metadata,
1652
+ retry_policy: @config.retry_policy
1653
+
1654
+ @cloud_tasks_stub.acknowledge_task request, options do |result, operation|
1655
+ yield result, operation if block_given?
1656
+ return result
1657
+ end
1658
+ rescue ::Gapic::Rest::Error => e
1659
+ raise ::Google::Cloud::Error.from_error(e)
1660
+ end
1661
+
1662
+ ##
1663
+ # Renew the current lease of a pull task.
1664
+ #
1665
+ # The worker can use this method to extend the lease by a new
1666
+ # duration, starting from now. The new task lease will be
1667
+ # returned in the task's {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}.
1668
+ #
1669
+ # @overload renew_lease(request, options = nil)
1670
+ # Pass arguments to `renew_lease` via a request object, either of type
1671
+ # {::Google::Cloud::Tasks::V2beta2::RenewLeaseRequest} or an equivalent Hash.
1672
+ #
1673
+ # @param request [::Google::Cloud::Tasks::V2beta2::RenewLeaseRequest, ::Hash]
1674
+ # A request object representing the call parameters. Required. To specify no
1675
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1676
+ # @param options [::Gapic::CallOptions, ::Hash]
1677
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1678
+ #
1679
+ # @overload renew_lease(name: nil, schedule_time: nil, lease_duration: nil, response_view: nil)
1680
+ # Pass arguments to `renew_lease` via keyword arguments. Note that at
1681
+ # least one keyword argument is required. To specify no parameters, or to keep all
1682
+ # the default parameter values, pass an empty Hash as a request object (see above).
1683
+ #
1684
+ # @param name [::String]
1685
+ # Required. The task name. For example:
1686
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1687
+ # @param schedule_time [::Google::Protobuf::Timestamp, ::Hash]
1688
+ # Required. The task's current schedule time, available in the
1689
+ # {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
1690
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks LeaseTasks} response or
1691
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#renew_lease RenewLease} response. This restriction is
1692
+ # to ensure that your worker currently holds the lease.
1693
+ # @param lease_duration [::Google::Protobuf::Duration, ::Hash]
1694
+ # Required. The desired new lease duration, starting from now.
1695
+ #
1696
+ #
1697
+ # The maximum lease duration is 1 week.
1698
+ # `lease_duration` will be truncated to the nearest second.
1699
+ # @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View]
1700
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be
1701
+ # returned.
1702
+ #
1703
+ # By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1704
+ # information is retrieved by default because some data, such as
1705
+ # payloads, might be desirable to return only when needed because
1706
+ # of its large size or because of the sensitivity of data that it
1707
+ # contains.
1708
+ #
1709
+ # Authorization for {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1710
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1711
+ # permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
1712
+ # @yield [result, operation] Access the result along with the TransportOperation object
1713
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Task]
1714
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1715
+ #
1716
+ # @return [::Google::Cloud::Tasks::V2beta2::Task]
1717
+ #
1718
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1719
+ def renew_lease request, options = nil
1720
+ raise ::ArgumentError, "request must be provided" if request.nil?
1721
+
1722
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::RenewLeaseRequest
1723
+
1724
+ # Converts hash and nil to an options object
1725
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1726
+
1727
+ # Customize the options with defaults
1728
+ call_metadata = @config.rpcs.renew_lease.metadata.to_h
1729
+
1730
+ # Set x-goog-api-client and x-goog-user-project headers
1731
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1732
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1733
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1734
+ transports_version_send: [:rest]
1735
+
1736
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1737
+
1738
+ options.apply_defaults timeout: @config.rpcs.renew_lease.timeout,
1739
+ metadata: call_metadata,
1740
+ retry_policy: @config.rpcs.renew_lease.retry_policy
1741
+
1742
+ options.apply_defaults timeout: @config.timeout,
1743
+ metadata: @config.metadata,
1744
+ retry_policy: @config.retry_policy
1745
+
1746
+ @cloud_tasks_stub.renew_lease request, options do |result, operation|
1747
+ yield result, operation if block_given?
1748
+ return result
1749
+ end
1750
+ rescue ::Gapic::Rest::Error => e
1751
+ raise ::Google::Cloud::Error.from_error(e)
1752
+ end
1753
+
1754
+ ##
1755
+ # Cancel a pull task's lease.
1756
+ #
1757
+ # The worker can use this method to cancel a task's lease by
1758
+ # setting its {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} to now. This will
1759
+ # make the task available to be leased to the next caller of
1760
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks LeaseTasks}.
1761
+ #
1762
+ # @overload cancel_lease(request, options = nil)
1763
+ # Pass arguments to `cancel_lease` via a request object, either of type
1764
+ # {::Google::Cloud::Tasks::V2beta2::CancelLeaseRequest} or an equivalent Hash.
1765
+ #
1766
+ # @param request [::Google::Cloud::Tasks::V2beta2::CancelLeaseRequest, ::Hash]
1767
+ # A request object representing the call parameters. Required. To specify no
1768
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1769
+ # @param options [::Gapic::CallOptions, ::Hash]
1770
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1771
+ #
1772
+ # @overload cancel_lease(name: nil, schedule_time: nil, response_view: nil)
1773
+ # Pass arguments to `cancel_lease` via keyword arguments. Note that at
1774
+ # least one keyword argument is required. To specify no parameters, or to keep all
1775
+ # the default parameter values, pass an empty Hash as a request object (see above).
1776
+ #
1777
+ # @param name [::String]
1778
+ # Required. The task name. For example:
1779
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1780
+ # @param schedule_time [::Google::Protobuf::Timestamp, ::Hash]
1781
+ # Required. The task's current schedule time, available in the
1782
+ # {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
1783
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#lease_tasks LeaseTasks} response or
1784
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#renew_lease RenewLease} response. This restriction is
1785
+ # to ensure that your worker currently holds the lease.
1786
+ # @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View]
1787
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be
1788
+ # returned.
1789
+ #
1790
+ # By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1791
+ # information is retrieved by default because some data, such as
1792
+ # payloads, might be desirable to return only when needed because
1793
+ # of its large size or because of the sensitivity of data that it
1794
+ # contains.
1795
+ #
1796
+ # Authorization for {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1797
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1798
+ # permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
1799
+ # @yield [result, operation] Access the result along with the TransportOperation object
1800
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Task]
1801
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1802
+ #
1803
+ # @return [::Google::Cloud::Tasks::V2beta2::Task]
1804
+ #
1805
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1806
+ def cancel_lease request, options = nil
1807
+ raise ::ArgumentError, "request must be provided" if request.nil?
1808
+
1809
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::CancelLeaseRequest
1810
+
1811
+ # Converts hash and nil to an options object
1812
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1813
+
1814
+ # Customize the options with defaults
1815
+ call_metadata = @config.rpcs.cancel_lease.metadata.to_h
1816
+
1817
+ # Set x-goog-api-client and x-goog-user-project headers
1818
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1819
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1820
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1821
+ transports_version_send: [:rest]
1822
+
1823
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1824
+
1825
+ options.apply_defaults timeout: @config.rpcs.cancel_lease.timeout,
1826
+ metadata: call_metadata,
1827
+ retry_policy: @config.rpcs.cancel_lease.retry_policy
1828
+
1829
+ options.apply_defaults timeout: @config.timeout,
1830
+ metadata: @config.metadata,
1831
+ retry_policy: @config.retry_policy
1832
+
1833
+ @cloud_tasks_stub.cancel_lease request, options do |result, operation|
1834
+ yield result, operation if block_given?
1835
+ return result
1836
+ end
1837
+ rescue ::Gapic::Rest::Error => e
1838
+ raise ::Google::Cloud::Error.from_error(e)
1839
+ end
1840
+
1841
+ ##
1842
+ # Forces a task to run now.
1843
+ #
1844
+ # When this method is called, Cloud Tasks will dispatch the task, even if
1845
+ # the task is already running, the queue has reached its {::Google::Cloud::Tasks::V2beta2::RateLimits RateLimits} or
1846
+ # is {::Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
1847
+ #
1848
+ # This command is meant to be used for manual debugging. For
1849
+ # example, {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#run_task RunTask} can be used to retry a failed
1850
+ # task after a fix has been made or to manually force a task to be
1851
+ # dispatched now.
1852
+ #
1853
+ # The dispatched task is returned. That is, the task that is returned
1854
+ # contains the {::Google::Cloud::Tasks::V2beta2::Task#status status} after the task is dispatched but
1855
+ # before the task is received by its target.
1856
+ #
1857
+ # If Cloud Tasks receives a successful response from the task's
1858
+ # target, then the task will be deleted; otherwise the task's
1859
+ # {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be reset to the time that
1860
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#run_task RunTask} was called plus the retry delay specified
1861
+ # in the queue's {::Google::Cloud::Tasks::V2beta2::RetryConfig RetryConfig}.
1862
+ #
1863
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#run_task RunTask} returns
1864
+ # [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a
1865
+ # task that has already succeeded or permanently failed.
1866
+ #
1867
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#run_task RunTask} cannot be called on a
1868
+ # {::Google::Cloud::Tasks::V2beta2::PullMessage pull task}.
1869
+ #
1870
+ # @overload run_task(request, options = nil)
1871
+ # Pass arguments to `run_task` via a request object, either of type
1872
+ # {::Google::Cloud::Tasks::V2beta2::RunTaskRequest} or an equivalent Hash.
1873
+ #
1874
+ # @param request [::Google::Cloud::Tasks::V2beta2::RunTaskRequest, ::Hash]
1875
+ # A request object representing the call parameters. Required. To specify no
1876
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1877
+ # @param options [::Gapic::CallOptions, ::Hash]
1878
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1879
+ #
1880
+ # @overload run_task(name: nil, response_view: nil)
1881
+ # Pass arguments to `run_task` via keyword arguments. Note that at
1882
+ # least one keyword argument is required. To specify no parameters, or to keep all
1883
+ # the default parameter values, pass an empty Hash as a request object (see above).
1884
+ #
1885
+ # @param name [::String]
1886
+ # Required. The task name. For example:
1887
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1888
+ # @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View]
1889
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be
1890
+ # returned.
1891
+ #
1892
+ # By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1893
+ # information is retrieved by default because some data, such as
1894
+ # payloads, might be desirable to return only when needed because
1895
+ # of its large size or because of the sensitivity of data that it
1896
+ # contains.
1897
+ #
1898
+ # Authorization for {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1899
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1900
+ # permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
1901
+ # @yield [result, operation] Access the result along with the TransportOperation object
1902
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::Task]
1903
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1904
+ #
1905
+ # @return [::Google::Cloud::Tasks::V2beta2::Task]
1906
+ #
1907
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1908
+ def run_task request, options = nil
1909
+ raise ::ArgumentError, "request must be provided" if request.nil?
1910
+
1911
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::RunTaskRequest
1912
+
1913
+ # Converts hash and nil to an options object
1914
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1915
+
1916
+ # Customize the options with defaults
1917
+ call_metadata = @config.rpcs.run_task.metadata.to_h
1918
+
1919
+ # Set x-goog-api-client and x-goog-user-project headers
1920
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1921
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1922
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
1923
+ transports_version_send: [:rest]
1924
+
1925
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1926
+
1927
+ options.apply_defaults timeout: @config.rpcs.run_task.timeout,
1928
+ metadata: call_metadata,
1929
+ retry_policy: @config.rpcs.run_task.retry_policy
1930
+
1931
+ options.apply_defaults timeout: @config.timeout,
1932
+ metadata: @config.metadata,
1933
+ retry_policy: @config.retry_policy
1934
+
1935
+ @cloud_tasks_stub.run_task request, options do |result, operation|
1936
+ yield result, operation if block_given?
1937
+ return result
1938
+ end
1939
+ rescue ::Gapic::Rest::Error => e
1940
+ raise ::Google::Cloud::Error.from_error(e)
1941
+ end
1942
+
1943
+ ##
1944
+ # Configuration class for the CloudTasks REST API.
1945
+ #
1946
+ # This class represents the configuration for CloudTasks REST,
1947
+ # providing control over timeouts, retry behavior, logging, transport
1948
+ # parameters, and other low-level controls. Certain parameters can also be
1949
+ # applied individually to specific RPCs. See
1950
+ # {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client::Configuration::Rpcs}
1951
+ # for a list of RPCs that can be configured independently.
1952
+ #
1953
+ # Configuration can be applied globally to all clients, or to a single client
1954
+ # on construction.
1955
+ #
1956
+ # @example
1957
+ #
1958
+ # # Modify the global config, setting the timeout for
1959
+ # # list_queues to 20 seconds,
1960
+ # # and all remaining timeouts to 10 seconds.
1961
+ # ::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client.configure do |config|
1962
+ # config.timeout = 10.0
1963
+ # config.rpcs.list_queues.timeout = 20.0
1964
+ # end
1965
+ #
1966
+ # # Apply the above configuration only to a new client.
1967
+ # client = ::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client.new do |config|
1968
+ # config.timeout = 10.0
1969
+ # config.rpcs.list_queues.timeout = 20.0
1970
+ # end
1971
+ #
1972
+ # @!attribute [rw] endpoint
1973
+ # The hostname or hostname:port of the service endpoint.
1974
+ # Defaults to `"cloudtasks.googleapis.com"`.
1975
+ # @return [::String]
1976
+ # @!attribute [rw] credentials
1977
+ # Credentials to send with calls. You may provide any of the following types:
1978
+ # * (`String`) The path to a service account key file in JSON format
1979
+ # * (`Hash`) A service account key as a Hash
1980
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1981
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
1982
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1983
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
1984
+ # * (`nil`) indicating no credentials
1985
+ # @return [::Object]
1986
+ # @!attribute [rw] scope
1987
+ # The OAuth scopes
1988
+ # @return [::Array<::String>]
1989
+ # @!attribute [rw] lib_name
1990
+ # The library name as recorded in instrumentation and logging
1991
+ # @return [::String]
1992
+ # @!attribute [rw] lib_version
1993
+ # The library version as recorded in instrumentation and logging
1994
+ # @return [::String]
1995
+ # @!attribute [rw] timeout
1996
+ # The call timeout in seconds.
1997
+ # @return [::Numeric]
1998
+ # @!attribute [rw] metadata
1999
+ # Additional headers to be sent with the call.
2000
+ # @return [::Hash{::Symbol=>::String}]
2001
+ # @!attribute [rw] retry_policy
2002
+ # The retry policy. The value is a hash with the following keys:
2003
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
2004
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
2005
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
2006
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
2007
+ # trigger a retry.
2008
+ # @return [::Hash]
2009
+ # @!attribute [rw] quota_project
2010
+ # A separate project against which to charge quota.
2011
+ # @return [::String]
2012
+ #
2013
+ class Configuration
2014
+ extend ::Gapic::Config
2015
+
2016
+ config_attr :endpoint, "cloudtasks.googleapis.com", ::String
2017
+ config_attr :credentials, nil do |value|
2018
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
2019
+ allowed.any? { |klass| klass === value }
2020
+ end
2021
+ config_attr :scope, nil, ::String, ::Array, nil
2022
+ config_attr :lib_name, nil, ::String, nil
2023
+ config_attr :lib_version, nil, ::String, nil
2024
+ config_attr :timeout, nil, ::Numeric, nil
2025
+ config_attr :metadata, nil, ::Hash, nil
2026
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2027
+ config_attr :quota_project, nil, ::String, nil
2028
+
2029
+ # @private
2030
+ def initialize parent_config = nil
2031
+ @parent_config = parent_config unless parent_config.nil?
2032
+
2033
+ yield self if block_given?
2034
+ end
2035
+
2036
+ ##
2037
+ # Configurations for individual RPCs
2038
+ # @return [Rpcs]
2039
+ #
2040
+ def rpcs
2041
+ @rpcs ||= begin
2042
+ parent_rpcs = nil
2043
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
2044
+ Rpcs.new parent_rpcs
2045
+ end
2046
+ end
2047
+
2048
+ ##
2049
+ # Configuration RPC class for the CloudTasks API.
2050
+ #
2051
+ # Includes fields providing the configuration for each RPC in this service.
2052
+ # Each configuration object is of type `Gapic::Config::Method` and includes
2053
+ # the following configuration fields:
2054
+ #
2055
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
2056
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
2057
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
2058
+ # include the following keys:
2059
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
2060
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
2061
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
2062
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
2063
+ # trigger a retry.
2064
+ #
2065
+ class Rpcs
2066
+ ##
2067
+ # RPC-specific configuration for `list_queues`
2068
+ # @return [::Gapic::Config::Method]
2069
+ #
2070
+ attr_reader :list_queues
2071
+ ##
2072
+ # RPC-specific configuration for `get_queue`
2073
+ # @return [::Gapic::Config::Method]
2074
+ #
2075
+ attr_reader :get_queue
2076
+ ##
2077
+ # RPC-specific configuration for `create_queue`
2078
+ # @return [::Gapic::Config::Method]
2079
+ #
2080
+ attr_reader :create_queue
2081
+ ##
2082
+ # RPC-specific configuration for `update_queue`
2083
+ # @return [::Gapic::Config::Method]
2084
+ #
2085
+ attr_reader :update_queue
2086
+ ##
2087
+ # RPC-specific configuration for `delete_queue`
2088
+ # @return [::Gapic::Config::Method]
2089
+ #
2090
+ attr_reader :delete_queue
2091
+ ##
2092
+ # RPC-specific configuration for `purge_queue`
2093
+ # @return [::Gapic::Config::Method]
2094
+ #
2095
+ attr_reader :purge_queue
2096
+ ##
2097
+ # RPC-specific configuration for `pause_queue`
2098
+ # @return [::Gapic::Config::Method]
2099
+ #
2100
+ attr_reader :pause_queue
2101
+ ##
2102
+ # RPC-specific configuration for `resume_queue`
2103
+ # @return [::Gapic::Config::Method]
2104
+ #
2105
+ attr_reader :resume_queue
2106
+ ##
2107
+ # RPC-specific configuration for `get_iam_policy`
2108
+ # @return [::Gapic::Config::Method]
2109
+ #
2110
+ attr_reader :get_iam_policy
2111
+ ##
2112
+ # RPC-specific configuration for `set_iam_policy`
2113
+ # @return [::Gapic::Config::Method]
2114
+ #
2115
+ attr_reader :set_iam_policy
2116
+ ##
2117
+ # RPC-specific configuration for `test_iam_permissions`
2118
+ # @return [::Gapic::Config::Method]
2119
+ #
2120
+ attr_reader :test_iam_permissions
2121
+ ##
2122
+ # RPC-specific configuration for `list_tasks`
2123
+ # @return [::Gapic::Config::Method]
2124
+ #
2125
+ attr_reader :list_tasks
2126
+ ##
2127
+ # RPC-specific configuration for `get_task`
2128
+ # @return [::Gapic::Config::Method]
2129
+ #
2130
+ attr_reader :get_task
2131
+ ##
2132
+ # RPC-specific configuration for `create_task`
2133
+ # @return [::Gapic::Config::Method]
2134
+ #
2135
+ attr_reader :create_task
2136
+ ##
2137
+ # RPC-specific configuration for `delete_task`
2138
+ # @return [::Gapic::Config::Method]
2139
+ #
2140
+ attr_reader :delete_task
2141
+ ##
2142
+ # RPC-specific configuration for `lease_tasks`
2143
+ # @return [::Gapic::Config::Method]
2144
+ #
2145
+ attr_reader :lease_tasks
2146
+ ##
2147
+ # RPC-specific configuration for `acknowledge_task`
2148
+ # @return [::Gapic::Config::Method]
2149
+ #
2150
+ attr_reader :acknowledge_task
2151
+ ##
2152
+ # RPC-specific configuration for `renew_lease`
2153
+ # @return [::Gapic::Config::Method]
2154
+ #
2155
+ attr_reader :renew_lease
2156
+ ##
2157
+ # RPC-specific configuration for `cancel_lease`
2158
+ # @return [::Gapic::Config::Method]
2159
+ #
2160
+ attr_reader :cancel_lease
2161
+ ##
2162
+ # RPC-specific configuration for `run_task`
2163
+ # @return [::Gapic::Config::Method]
2164
+ #
2165
+ attr_reader :run_task
2166
+
2167
+ # @private
2168
+ def initialize parent_rpcs = nil
2169
+ list_queues_config = parent_rpcs.list_queues if parent_rpcs.respond_to? :list_queues
2170
+ @list_queues = ::Gapic::Config::Method.new list_queues_config
2171
+ get_queue_config = parent_rpcs.get_queue if parent_rpcs.respond_to? :get_queue
2172
+ @get_queue = ::Gapic::Config::Method.new get_queue_config
2173
+ create_queue_config = parent_rpcs.create_queue if parent_rpcs.respond_to? :create_queue
2174
+ @create_queue = ::Gapic::Config::Method.new create_queue_config
2175
+ update_queue_config = parent_rpcs.update_queue if parent_rpcs.respond_to? :update_queue
2176
+ @update_queue = ::Gapic::Config::Method.new update_queue_config
2177
+ delete_queue_config = parent_rpcs.delete_queue if parent_rpcs.respond_to? :delete_queue
2178
+ @delete_queue = ::Gapic::Config::Method.new delete_queue_config
2179
+ purge_queue_config = parent_rpcs.purge_queue if parent_rpcs.respond_to? :purge_queue
2180
+ @purge_queue = ::Gapic::Config::Method.new purge_queue_config
2181
+ pause_queue_config = parent_rpcs.pause_queue if parent_rpcs.respond_to? :pause_queue
2182
+ @pause_queue = ::Gapic::Config::Method.new pause_queue_config
2183
+ resume_queue_config = parent_rpcs.resume_queue if parent_rpcs.respond_to? :resume_queue
2184
+ @resume_queue = ::Gapic::Config::Method.new resume_queue_config
2185
+ get_iam_policy_config = parent_rpcs.get_iam_policy if parent_rpcs.respond_to? :get_iam_policy
2186
+ @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
2187
+ set_iam_policy_config = parent_rpcs.set_iam_policy if parent_rpcs.respond_to? :set_iam_policy
2188
+ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
2189
+ test_iam_permissions_config = parent_rpcs.test_iam_permissions if parent_rpcs.respond_to? :test_iam_permissions
2190
+ @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
2191
+ list_tasks_config = parent_rpcs.list_tasks if parent_rpcs.respond_to? :list_tasks
2192
+ @list_tasks = ::Gapic::Config::Method.new list_tasks_config
2193
+ get_task_config = parent_rpcs.get_task if parent_rpcs.respond_to? :get_task
2194
+ @get_task = ::Gapic::Config::Method.new get_task_config
2195
+ create_task_config = parent_rpcs.create_task if parent_rpcs.respond_to? :create_task
2196
+ @create_task = ::Gapic::Config::Method.new create_task_config
2197
+ delete_task_config = parent_rpcs.delete_task if parent_rpcs.respond_to? :delete_task
2198
+ @delete_task = ::Gapic::Config::Method.new delete_task_config
2199
+ lease_tasks_config = parent_rpcs.lease_tasks if parent_rpcs.respond_to? :lease_tasks
2200
+ @lease_tasks = ::Gapic::Config::Method.new lease_tasks_config
2201
+ acknowledge_task_config = parent_rpcs.acknowledge_task if parent_rpcs.respond_to? :acknowledge_task
2202
+ @acknowledge_task = ::Gapic::Config::Method.new acknowledge_task_config
2203
+ renew_lease_config = parent_rpcs.renew_lease if parent_rpcs.respond_to? :renew_lease
2204
+ @renew_lease = ::Gapic::Config::Method.new renew_lease_config
2205
+ cancel_lease_config = parent_rpcs.cancel_lease if parent_rpcs.respond_to? :cancel_lease
2206
+ @cancel_lease = ::Gapic::Config::Method.new cancel_lease_config
2207
+ run_task_config = parent_rpcs.run_task if parent_rpcs.respond_to? :run_task
2208
+ @run_task = ::Gapic::Config::Method.new run_task_config
2209
+
2210
+ yield self if block_given?
2211
+ end
2212
+ end
2213
+ end
2214
+ end
2215
+ end
2216
+ end
2217
+ end
2218
+ end
2219
+ end
2220
+ end