google-cloud-tasks-v2beta2 0.7.0 → 0.9.0

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