google-cloud-tasks-v2 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1751 @@
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/v2/cloudtasks_pb"
21
+ require "google/cloud/tasks/v2/cloud_tasks/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Tasks
26
+ module V2
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::V2::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::V2::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", "V2"]
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 = 10.0
71
+ default_config.rpcs.list_queues.retry_policy = {
72
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
73
+ }
74
+
75
+ default_config.rpcs.get_queue.timeout = 10.0
76
+ default_config.rpcs.get_queue.retry_policy = {
77
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
78
+ }
79
+
80
+ default_config.rpcs.create_queue.timeout = 10.0
81
+
82
+ default_config.rpcs.update_queue.timeout = 10.0
83
+
84
+ default_config.rpcs.delete_queue.timeout = 10.0
85
+ default_config.rpcs.delete_queue.retry_policy = {
86
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
87
+ }
88
+
89
+ default_config.rpcs.purge_queue.timeout = 10.0
90
+
91
+ default_config.rpcs.pause_queue.timeout = 10.0
92
+
93
+ default_config.rpcs.resume_queue.timeout = 10.0
94
+
95
+ default_config.rpcs.get_iam_policy.timeout = 10.0
96
+ default_config.rpcs.get_iam_policy.retry_policy = {
97
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
98
+ }
99
+
100
+ default_config.rpcs.set_iam_policy.timeout = 10.0
101
+
102
+ default_config.rpcs.test_iam_permissions.timeout = 10.0
103
+ default_config.rpcs.test_iam_permissions.retry_policy = {
104
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
105
+ }
106
+
107
+ default_config.rpcs.list_tasks.timeout = 10.0
108
+ default_config.rpcs.list_tasks.retry_policy = {
109
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
110
+ }
111
+
112
+ default_config.rpcs.get_task.timeout = 10.0
113
+ default_config.rpcs.get_task.retry_policy = {
114
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
115
+ }
116
+
117
+ default_config.rpcs.create_task.timeout = 10.0
118
+
119
+ default_config.rpcs.delete_task.timeout = 10.0
120
+ default_config.rpcs.delete_task.retry_policy = {
121
+ initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
122
+ }
123
+
124
+ default_config.rpcs.run_task.timeout = 10.0
125
+
126
+ default_config
127
+ end
128
+ yield @configure if block_given?
129
+ @configure
130
+ end
131
+
132
+ ##
133
+ # Configure the CloudTasks Client instance.
134
+ #
135
+ # The configuration is set to the derived mode, meaning that values can be changed,
136
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
137
+ # should be made on {Client.configure}.
138
+ #
139
+ # See {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client::Configuration}
140
+ # for a description of the configuration fields.
141
+ #
142
+ # @yield [config] Configure the Client client.
143
+ # @yieldparam config [Client::Configuration]
144
+ #
145
+ # @return [Client::Configuration]
146
+ #
147
+ def configure
148
+ yield @config if block_given?
149
+ @config
150
+ end
151
+
152
+ ##
153
+ # Create a new CloudTasks REST client object.
154
+ #
155
+ # @example
156
+ #
157
+ # # Create a client using the default configuration
158
+ # client = ::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client.new
159
+ #
160
+ # # Create a client using a custom configuration
161
+ # client = ::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client.new do |config|
162
+ # config.timeout = 10.0
163
+ # end
164
+ #
165
+ # @yield [config] Configure the CloudTasks client.
166
+ # @yieldparam config [Client::Configuration]
167
+ #
168
+ def initialize
169
+ # Create the configuration object
170
+ @config = Configuration.new Client.configure
171
+
172
+ # Yield the configuration if needed
173
+ yield @config if block_given?
174
+
175
+ # Create credentials
176
+ credentials = @config.credentials
177
+ # Use self-signed JWT if the endpoint is unchanged from default,
178
+ # but only if the default endpoint does not have a region prefix.
179
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
180
+ !@config.endpoint.split(".").first.include?("-")
181
+ credentials ||= Credentials.default scope: @config.scope,
182
+ enable_self_signed_jwt: enable_self_signed_jwt
183
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
184
+ credentials = Credentials.new credentials, scope: @config.scope
185
+ end
186
+
187
+ @quota_project_id = @config.quota_project
188
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
189
+
190
+ @cloud_tasks_stub = ::Google::Cloud::Tasks::V2::CloudTasks::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
191
+ end
192
+
193
+ # Service calls
194
+
195
+ ##
196
+ # Lists queues.
197
+ #
198
+ # Queues are returned in lexicographical order.
199
+ #
200
+ # @overload list_queues(request, options = nil)
201
+ # Pass arguments to `list_queues` via a request object, either of type
202
+ # {::Google::Cloud::Tasks::V2::ListQueuesRequest} or an equivalent Hash.
203
+ #
204
+ # @param request [::Google::Cloud::Tasks::V2::ListQueuesRequest, ::Hash]
205
+ # A request object representing the call parameters. Required. To specify no
206
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
207
+ # @param options [::Gapic::CallOptions, ::Hash]
208
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
209
+ #
210
+ # @overload list_queues(parent: nil, filter: nil, page_size: nil, page_token: nil)
211
+ # Pass arguments to `list_queues` via keyword arguments. Note that at
212
+ # least one keyword argument is required. To specify no parameters, or to keep all
213
+ # the default parameter values, pass an empty Hash as a request object (see above).
214
+ #
215
+ # @param parent [::String]
216
+ # Required. The location name.
217
+ # For example: `projects/PROJECT_ID/locations/LOCATION_ID`
218
+ # @param filter [::String]
219
+ # `filter` can be used to specify a subset of queues. Any {::Google::Cloud::Tasks::V2::Queue Queue}
220
+ # field can be used as a filter and several operators as supported.
221
+ # For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as
222
+ # described in
223
+ # [Stackdriver's Advanced Logs
224
+ # Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
225
+ #
226
+ # Sample filter "state: PAUSED".
227
+ #
228
+ # Note that using filters might cause fewer queues than the
229
+ # requested page_size to be returned.
230
+ # @param page_size [::Integer]
231
+ # Requested page size.
232
+ #
233
+ # The maximum page size is 9800. If unspecified, the page size will
234
+ # be the maximum. Fewer queues than requested might be returned,
235
+ # even if more queues exist; use the
236
+ # {::Google::Cloud::Tasks::V2::ListQueuesResponse#next_page_token next_page_token} in the
237
+ # response to determine if more queues exist.
238
+ # @param page_token [::String]
239
+ # A token identifying the page of results to return.
240
+ #
241
+ # To request the first page results, page_token must be empty. To
242
+ # request the next page of results, page_token must be the value of
243
+ # {::Google::Cloud::Tasks::V2::ListQueuesResponse#next_page_token next_page_token} returned
244
+ # from the previous call to {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client#list_queues ListQueues}
245
+ # method. It is an error to switch the value of the
246
+ # {::Google::Cloud::Tasks::V2::ListQueuesRequest#filter filter} while iterating through pages.
247
+ # @yield [result, operation] Access the result along with the TransportOperation object
248
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Tasks::V2::Queue>]
249
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
250
+ #
251
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Tasks::V2::Queue>]
252
+ #
253
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
254
+ def list_queues request, options = nil
255
+ raise ::ArgumentError, "request must be provided" if request.nil?
256
+
257
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::ListQueuesRequest
258
+
259
+ # Converts hash and nil to an options object
260
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
261
+
262
+ # Customize the options with defaults
263
+ call_metadata = @config.rpcs.list_queues.metadata.to_h
264
+
265
+ # Set x-goog-api-client and x-goog-user-project headers
266
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
267
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
268
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
269
+ transports_version_send: [:rest]
270
+
271
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
272
+
273
+ options.apply_defaults timeout: @config.rpcs.list_queues.timeout,
274
+ metadata: call_metadata,
275
+ retry_policy: @config.rpcs.list_queues.retry_policy
276
+
277
+ options.apply_defaults timeout: @config.timeout,
278
+ metadata: @config.metadata,
279
+ retry_policy: @config.retry_policy
280
+
281
+ @cloud_tasks_stub.list_queues request, options do |result, operation|
282
+ result = ::Gapic::Rest::PagedEnumerable.new @cloud_tasks_stub, :list_queues, "queues", request, result, options
283
+ yield result, operation if block_given?
284
+ return result
285
+ end
286
+ rescue ::Gapic::Rest::Error => e
287
+ raise ::Google::Cloud::Error.from_error(e)
288
+ end
289
+
290
+ ##
291
+ # Gets a queue.
292
+ #
293
+ # @overload get_queue(request, options = nil)
294
+ # Pass arguments to `get_queue` via a request object, either of type
295
+ # {::Google::Cloud::Tasks::V2::GetQueueRequest} or an equivalent Hash.
296
+ #
297
+ # @param request [::Google::Cloud::Tasks::V2::GetQueueRequest, ::Hash]
298
+ # A request object representing the call parameters. Required. To specify no
299
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
300
+ # @param options [::Gapic::CallOptions, ::Hash]
301
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
302
+ #
303
+ # @overload get_queue(name: nil)
304
+ # Pass arguments to `get_queue` via keyword arguments. Note that at
305
+ # least one keyword argument is required. To specify no parameters, or to keep all
306
+ # the default parameter values, pass an empty Hash as a request object (see above).
307
+ #
308
+ # @param name [::String]
309
+ # Required. The resource name of the queue. For example:
310
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
311
+ # @yield [result, operation] Access the result along with the TransportOperation object
312
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Queue]
313
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
314
+ #
315
+ # @return [::Google::Cloud::Tasks::V2::Queue]
316
+ #
317
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
318
+ def get_queue request, options = nil
319
+ raise ::ArgumentError, "request must be provided" if request.nil?
320
+
321
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::GetQueueRequest
322
+
323
+ # Converts hash and nil to an options object
324
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
325
+
326
+ # Customize the options with defaults
327
+ call_metadata = @config.rpcs.get_queue.metadata.to_h
328
+
329
+ # Set x-goog-api-client and x-goog-user-project headers
330
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
331
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
332
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
333
+ transports_version_send: [:rest]
334
+
335
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
336
+
337
+ options.apply_defaults timeout: @config.rpcs.get_queue.timeout,
338
+ metadata: call_metadata,
339
+ retry_policy: @config.rpcs.get_queue.retry_policy
340
+
341
+ options.apply_defaults timeout: @config.timeout,
342
+ metadata: @config.metadata,
343
+ retry_policy: @config.retry_policy
344
+
345
+ @cloud_tasks_stub.get_queue request, options do |result, operation|
346
+ yield result, operation if block_given?
347
+ return result
348
+ end
349
+ rescue ::Gapic::Rest::Error => e
350
+ raise ::Google::Cloud::Error.from_error(e)
351
+ end
352
+
353
+ ##
354
+ # Creates a queue.
355
+ #
356
+ # Queues created with this method allow tasks to live for a maximum of 31
357
+ # days. After a task is 31 days old, the task will be deleted regardless of whether
358
+ # it was dispatched or not.
359
+ #
360
+ # WARNING: Using this method may have unintended side effects if you are
361
+ # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
362
+ # Read
363
+ # [Overview of Queue Management and
364
+ # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
365
+ # this method.
366
+ #
367
+ # @overload create_queue(request, options = nil)
368
+ # Pass arguments to `create_queue` via a request object, either of type
369
+ # {::Google::Cloud::Tasks::V2::CreateQueueRequest} or an equivalent Hash.
370
+ #
371
+ # @param request [::Google::Cloud::Tasks::V2::CreateQueueRequest, ::Hash]
372
+ # A request object representing the call parameters. Required. To specify no
373
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
374
+ # @param options [::Gapic::CallOptions, ::Hash]
375
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
376
+ #
377
+ # @overload create_queue(parent: nil, queue: nil)
378
+ # Pass arguments to `create_queue` via keyword arguments. Note that at
379
+ # least one keyword argument is required. To specify no parameters, or to keep all
380
+ # the default parameter values, pass an empty Hash as a request object (see above).
381
+ #
382
+ # @param parent [::String]
383
+ # Required. The location name in which the queue will be created.
384
+ # For example: `projects/PROJECT_ID/locations/LOCATION_ID`
385
+ #
386
+ # The list of allowed locations can be obtained by calling Cloud
387
+ # Tasks' implementation of
388
+ # [ListLocations][google.cloud.location.Locations.ListLocations].
389
+ # @param queue [::Google::Cloud::Tasks::V2::Queue, ::Hash]
390
+ # Required. The queue to create.
391
+ #
392
+ # [Queue's name][google.cloud.tasks.v2.Queue.name] cannot be the same as an existing queue.
393
+ # @yield [result, operation] Access the result along with the TransportOperation object
394
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Queue]
395
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
396
+ #
397
+ # @return [::Google::Cloud::Tasks::V2::Queue]
398
+ #
399
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
400
+ def create_queue request, options = nil
401
+ raise ::ArgumentError, "request must be provided" if request.nil?
402
+
403
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::CreateQueueRequest
404
+
405
+ # Converts hash and nil to an options object
406
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
407
+
408
+ # Customize the options with defaults
409
+ call_metadata = @config.rpcs.create_queue.metadata.to_h
410
+
411
+ # Set x-goog-api-client and x-goog-user-project headers
412
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
413
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
414
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
415
+ transports_version_send: [:rest]
416
+
417
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
418
+
419
+ options.apply_defaults timeout: @config.rpcs.create_queue.timeout,
420
+ metadata: call_metadata,
421
+ retry_policy: @config.rpcs.create_queue.retry_policy
422
+
423
+ options.apply_defaults timeout: @config.timeout,
424
+ metadata: @config.metadata,
425
+ retry_policy: @config.retry_policy
426
+
427
+ @cloud_tasks_stub.create_queue request, options do |result, operation|
428
+ yield result, operation if block_given?
429
+ return result
430
+ end
431
+ rescue ::Gapic::Rest::Error => e
432
+ raise ::Google::Cloud::Error.from_error(e)
433
+ end
434
+
435
+ ##
436
+ # Updates a queue.
437
+ #
438
+ # This method creates the queue if it does not exist and updates
439
+ # the queue if it does exist.
440
+ #
441
+ # Queues created with this method allow tasks to live for a maximum of 31
442
+ # days. After a task is 31 days old, the task will be deleted regardless of whether
443
+ # it was dispatched or not.
444
+ #
445
+ # WARNING: Using this method may have unintended side effects if you are
446
+ # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
447
+ # Read
448
+ # [Overview of Queue Management and
449
+ # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
450
+ # this method.
451
+ #
452
+ # @overload update_queue(request, options = nil)
453
+ # Pass arguments to `update_queue` via a request object, either of type
454
+ # {::Google::Cloud::Tasks::V2::UpdateQueueRequest} or an equivalent Hash.
455
+ #
456
+ # @param request [::Google::Cloud::Tasks::V2::UpdateQueueRequest, ::Hash]
457
+ # A request object representing the call parameters. Required. To specify no
458
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
459
+ # @param options [::Gapic::CallOptions, ::Hash]
460
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
461
+ #
462
+ # @overload update_queue(queue: nil, update_mask: nil)
463
+ # Pass arguments to `update_queue` via keyword arguments. Note that at
464
+ # least one keyword argument is required. To specify no parameters, or to keep all
465
+ # the default parameter values, pass an empty Hash as a request object (see above).
466
+ #
467
+ # @param queue [::Google::Cloud::Tasks::V2::Queue, ::Hash]
468
+ # Required. The queue to create or update.
469
+ #
470
+ # The queue's {::Google::Cloud::Tasks::V2::Queue#name name} must be specified.
471
+ #
472
+ # Output only fields cannot be modified using UpdateQueue.
473
+ # Any value specified for an output only field will be ignored.
474
+ # The queue's {::Google::Cloud::Tasks::V2::Queue#name name} cannot be changed.
475
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
476
+ # A mask used to specify which fields of the queue are being updated.
477
+ #
478
+ # If empty, then all fields will be updated.
479
+ # @yield [result, operation] Access the result along with the TransportOperation object
480
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Queue]
481
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
482
+ #
483
+ # @return [::Google::Cloud::Tasks::V2::Queue]
484
+ #
485
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
486
+ def update_queue request, options = nil
487
+ raise ::ArgumentError, "request must be provided" if request.nil?
488
+
489
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::UpdateQueueRequest
490
+
491
+ # Converts hash and nil to an options object
492
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
493
+
494
+ # Customize the options with defaults
495
+ call_metadata = @config.rpcs.update_queue.metadata.to_h
496
+
497
+ # Set x-goog-api-client and x-goog-user-project headers
498
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
499
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
500
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
501
+ transports_version_send: [:rest]
502
+
503
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
504
+
505
+ options.apply_defaults timeout: @config.rpcs.update_queue.timeout,
506
+ metadata: call_metadata,
507
+ retry_policy: @config.rpcs.update_queue.retry_policy
508
+
509
+ options.apply_defaults timeout: @config.timeout,
510
+ metadata: @config.metadata,
511
+ retry_policy: @config.retry_policy
512
+
513
+ @cloud_tasks_stub.update_queue request, options do |result, operation|
514
+ yield result, operation if block_given?
515
+ return result
516
+ end
517
+ rescue ::Gapic::Rest::Error => e
518
+ raise ::Google::Cloud::Error.from_error(e)
519
+ end
520
+
521
+ ##
522
+ # Deletes a queue.
523
+ #
524
+ # This command will delete the queue even if it has tasks in it.
525
+ #
526
+ # Note: If you delete a queue, a queue with the same name can't be created
527
+ # for 7 days.
528
+ #
529
+ # WARNING: Using this method may have unintended side effects if you are
530
+ # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
531
+ # Read
532
+ # [Overview of Queue Management and
533
+ # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
534
+ # this method.
535
+ #
536
+ # @overload delete_queue(request, options = nil)
537
+ # Pass arguments to `delete_queue` via a request object, either of type
538
+ # {::Google::Cloud::Tasks::V2::DeleteQueueRequest} or an equivalent Hash.
539
+ #
540
+ # @param request [::Google::Cloud::Tasks::V2::DeleteQueueRequest, ::Hash]
541
+ # A request object representing the call parameters. Required. To specify no
542
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
543
+ # @param options [::Gapic::CallOptions, ::Hash]
544
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
545
+ #
546
+ # @overload delete_queue(name: nil)
547
+ # Pass arguments to `delete_queue` via keyword arguments. Note that at
548
+ # least one keyword argument is required. To specify no parameters, or to keep all
549
+ # the default parameter values, pass an empty Hash as a request object (see above).
550
+ #
551
+ # @param name [::String]
552
+ # Required. The queue name. For example:
553
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
554
+ # @yield [result, operation] Access the result along with the TransportOperation object
555
+ # @yieldparam result [::Google::Protobuf::Empty]
556
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
557
+ #
558
+ # @return [::Google::Protobuf::Empty]
559
+ #
560
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
561
+ def delete_queue request, options = nil
562
+ raise ::ArgumentError, "request must be provided" if request.nil?
563
+
564
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::DeleteQueueRequest
565
+
566
+ # Converts hash and nil to an options object
567
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
568
+
569
+ # Customize the options with defaults
570
+ call_metadata = @config.rpcs.delete_queue.metadata.to_h
571
+
572
+ # Set x-goog-api-client and x-goog-user-project headers
573
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
574
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
575
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
576
+ transports_version_send: [:rest]
577
+
578
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
579
+
580
+ options.apply_defaults timeout: @config.rpcs.delete_queue.timeout,
581
+ metadata: call_metadata,
582
+ retry_policy: @config.rpcs.delete_queue.retry_policy
583
+
584
+ options.apply_defaults timeout: @config.timeout,
585
+ metadata: @config.metadata,
586
+ retry_policy: @config.retry_policy
587
+
588
+ @cloud_tasks_stub.delete_queue request, options do |result, operation|
589
+ yield result, operation if block_given?
590
+ return result
591
+ end
592
+ rescue ::Gapic::Rest::Error => e
593
+ raise ::Google::Cloud::Error.from_error(e)
594
+ end
595
+
596
+ ##
597
+ # Purges a queue by deleting all of its tasks.
598
+ #
599
+ # All tasks created before this method is called are permanently deleted.
600
+ #
601
+ # Purge operations can take up to one minute to take effect. Tasks
602
+ # might be dispatched before the purge takes effect. A purge is irreversible.
603
+ #
604
+ # @overload purge_queue(request, options = nil)
605
+ # Pass arguments to `purge_queue` via a request object, either of type
606
+ # {::Google::Cloud::Tasks::V2::PurgeQueueRequest} or an equivalent Hash.
607
+ #
608
+ # @param request [::Google::Cloud::Tasks::V2::PurgeQueueRequest, ::Hash]
609
+ # A request object representing the call parameters. Required. To specify no
610
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
611
+ # @param options [::Gapic::CallOptions, ::Hash]
612
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
613
+ #
614
+ # @overload purge_queue(name: nil)
615
+ # Pass arguments to `purge_queue` via keyword arguments. Note that at
616
+ # least one keyword argument is required. To specify no parameters, or to keep all
617
+ # the default parameter values, pass an empty Hash as a request object (see above).
618
+ #
619
+ # @param name [::String]
620
+ # Required. The queue name. For example:
621
+ # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
622
+ # @yield [result, operation] Access the result along with the TransportOperation object
623
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Queue]
624
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
625
+ #
626
+ # @return [::Google::Cloud::Tasks::V2::Queue]
627
+ #
628
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
629
+ def purge_queue request, options = nil
630
+ raise ::ArgumentError, "request must be provided" if request.nil?
631
+
632
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::PurgeQueueRequest
633
+
634
+ # Converts hash and nil to an options object
635
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
636
+
637
+ # Customize the options with defaults
638
+ call_metadata = @config.rpcs.purge_queue.metadata.to_h
639
+
640
+ # Set x-goog-api-client and x-goog-user-project headers
641
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
642
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
643
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
644
+ transports_version_send: [:rest]
645
+
646
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
647
+
648
+ options.apply_defaults timeout: @config.rpcs.purge_queue.timeout,
649
+ metadata: call_metadata,
650
+ retry_policy: @config.rpcs.purge_queue.retry_policy
651
+
652
+ options.apply_defaults timeout: @config.timeout,
653
+ metadata: @config.metadata,
654
+ retry_policy: @config.retry_policy
655
+
656
+ @cloud_tasks_stub.purge_queue request, options do |result, operation|
657
+ yield result, operation if block_given?
658
+ return result
659
+ end
660
+ rescue ::Gapic::Rest::Error => e
661
+ raise ::Google::Cloud::Error.from_error(e)
662
+ end
663
+
664
+ ##
665
+ # Pauses the queue.
666
+ #
667
+ # If a queue is paused then the system will stop dispatching tasks
668
+ # until the queue is resumed via
669
+ # {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client#resume_queue ResumeQueue}. Tasks can still be added
670
+ # when the queue is paused. A queue is paused if its
671
+ # {::Google::Cloud::Tasks::V2::Queue#state state} is {::Google::Cloud::Tasks::V2::Queue::State::PAUSED PAUSED}.
672
+ #
673
+ # @overload pause_queue(request, options = nil)
674
+ # Pass arguments to `pause_queue` via a request object, either of type
675
+ # {::Google::Cloud::Tasks::V2::PauseQueueRequest} or an equivalent Hash.
676
+ #
677
+ # @param request [::Google::Cloud::Tasks::V2::PauseQueueRequest, ::Hash]
678
+ # A request object representing the call parameters. Required. To specify no
679
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
680
+ # @param options [::Gapic::CallOptions, ::Hash]
681
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
682
+ #
683
+ # @overload pause_queue(name: nil)
684
+ # Pass arguments to `pause_queue` via keyword arguments. Note that at
685
+ # least one keyword argument is required. To specify no parameters, or to keep all
686
+ # the default parameter values, pass an empty Hash as a request object (see above).
687
+ #
688
+ # @param name [::String]
689
+ # Required. The queue name. For example:
690
+ # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
691
+ # @yield [result, operation] Access the result along with the TransportOperation object
692
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Queue]
693
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
694
+ #
695
+ # @return [::Google::Cloud::Tasks::V2::Queue]
696
+ #
697
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
698
+ def pause_queue request, options = nil
699
+ raise ::ArgumentError, "request must be provided" if request.nil?
700
+
701
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::PauseQueueRequest
702
+
703
+ # Converts hash and nil to an options object
704
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
705
+
706
+ # Customize the options with defaults
707
+ call_metadata = @config.rpcs.pause_queue.metadata.to_h
708
+
709
+ # Set x-goog-api-client and x-goog-user-project headers
710
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
711
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
712
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
713
+ transports_version_send: [:rest]
714
+
715
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
716
+
717
+ options.apply_defaults timeout: @config.rpcs.pause_queue.timeout,
718
+ metadata: call_metadata,
719
+ retry_policy: @config.rpcs.pause_queue.retry_policy
720
+
721
+ options.apply_defaults timeout: @config.timeout,
722
+ metadata: @config.metadata,
723
+ retry_policy: @config.retry_policy
724
+
725
+ @cloud_tasks_stub.pause_queue request, options do |result, operation|
726
+ yield result, operation if block_given?
727
+ return result
728
+ end
729
+ rescue ::Gapic::Rest::Error => e
730
+ raise ::Google::Cloud::Error.from_error(e)
731
+ end
732
+
733
+ ##
734
+ # Resume a queue.
735
+ #
736
+ # This method resumes a queue after it has been
737
+ # {::Google::Cloud::Tasks::V2::Queue::State::PAUSED PAUSED} or
738
+ # {::Google::Cloud::Tasks::V2::Queue::State::DISABLED DISABLED}. The state of a queue is stored
739
+ # in the queue's {::Google::Cloud::Tasks::V2::Queue#state state}; after calling this method it
740
+ # will be set to {::Google::Cloud::Tasks::V2::Queue::State::RUNNING RUNNING}.
741
+ #
742
+ # WARNING: Resuming many high-QPS queues at the same time can
743
+ # lead to target overloading. If you are resuming high-QPS
744
+ # queues, follow the 500/50/5 pattern described in
745
+ # [Managing Cloud Tasks Scaling
746
+ # Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
747
+ #
748
+ # @overload resume_queue(request, options = nil)
749
+ # Pass arguments to `resume_queue` via a request object, either of type
750
+ # {::Google::Cloud::Tasks::V2::ResumeQueueRequest} or an equivalent Hash.
751
+ #
752
+ # @param request [::Google::Cloud::Tasks::V2::ResumeQueueRequest, ::Hash]
753
+ # A request object representing the call parameters. Required. To specify no
754
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
755
+ # @param options [::Gapic::CallOptions, ::Hash]
756
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
757
+ #
758
+ # @overload resume_queue(name: nil)
759
+ # Pass arguments to `resume_queue` via keyword arguments. Note that at
760
+ # least one keyword argument is required. To specify no parameters, or to keep all
761
+ # the default parameter values, pass an empty Hash as a request object (see above).
762
+ #
763
+ # @param name [::String]
764
+ # Required. The queue name. For example:
765
+ # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
766
+ # @yield [result, operation] Access the result along with the TransportOperation object
767
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Queue]
768
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
769
+ #
770
+ # @return [::Google::Cloud::Tasks::V2::Queue]
771
+ #
772
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
773
+ def resume_queue request, options = nil
774
+ raise ::ArgumentError, "request must be provided" if request.nil?
775
+
776
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::ResumeQueueRequest
777
+
778
+ # Converts hash and nil to an options object
779
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
780
+
781
+ # Customize the options with defaults
782
+ call_metadata = @config.rpcs.resume_queue.metadata.to_h
783
+
784
+ # Set x-goog-api-client and x-goog-user-project headers
785
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
786
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
787
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
788
+ transports_version_send: [:rest]
789
+
790
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
791
+
792
+ options.apply_defaults timeout: @config.rpcs.resume_queue.timeout,
793
+ metadata: call_metadata,
794
+ retry_policy: @config.rpcs.resume_queue.retry_policy
795
+
796
+ options.apply_defaults timeout: @config.timeout,
797
+ metadata: @config.metadata,
798
+ retry_policy: @config.retry_policy
799
+
800
+ @cloud_tasks_stub.resume_queue request, options do |result, operation|
801
+ yield result, operation if block_given?
802
+ return result
803
+ end
804
+ rescue ::Gapic::Rest::Error => e
805
+ raise ::Google::Cloud::Error.from_error(e)
806
+ end
807
+
808
+ ##
809
+ # Gets the access control policy for a {::Google::Cloud::Tasks::V2::Queue Queue}.
810
+ # Returns an empty policy if the resource exists and does not have a policy
811
+ # set.
812
+ #
813
+ # Authorization requires the following
814
+ # [Google IAM](https://cloud.google.com/iam) permission on the specified
815
+ # resource parent:
816
+ #
817
+ # * `cloudtasks.queues.getIamPolicy`
818
+ #
819
+ # @overload get_iam_policy(request, options = nil)
820
+ # Pass arguments to `get_iam_policy` via a request object, either of type
821
+ # {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash.
822
+ #
823
+ # @param request [::Google::Iam::V1::GetIamPolicyRequest, ::Hash]
824
+ # A request object representing the call parameters. Required. To specify no
825
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
826
+ # @param options [::Gapic::CallOptions, ::Hash]
827
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
828
+ #
829
+ # @overload get_iam_policy(resource: nil, options: nil)
830
+ # Pass arguments to `get_iam_policy` via keyword arguments. Note that at
831
+ # least one keyword argument is required. To specify no parameters, or to keep all
832
+ # the default parameter values, pass an empty Hash as a request object (see above).
833
+ #
834
+ # @param resource [::String]
835
+ # REQUIRED: The resource for which the policy is being requested.
836
+ # See the operation documentation for the appropriate value for this field.
837
+ # @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash]
838
+ # OPTIONAL: A `GetPolicyOptions` object for specifying options to
839
+ # `GetIamPolicy`.
840
+ # @yield [result, operation] Access the result along with the TransportOperation object
841
+ # @yieldparam result [::Google::Iam::V1::Policy]
842
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
843
+ #
844
+ # @return [::Google::Iam::V1::Policy]
845
+ #
846
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
847
+ def get_iam_policy request, options = nil
848
+ raise ::ArgumentError, "request must be provided" if request.nil?
849
+
850
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest
851
+
852
+ # Converts hash and nil to an options object
853
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
854
+
855
+ # Customize the options with defaults
856
+ call_metadata = @config.rpcs.get_iam_policy.metadata.to_h
857
+
858
+ # Set x-goog-api-client and x-goog-user-project headers
859
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
860
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
861
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
862
+ transports_version_send: [:rest]
863
+
864
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
865
+
866
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
867
+ metadata: call_metadata,
868
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
869
+
870
+ options.apply_defaults timeout: @config.timeout,
871
+ metadata: @config.metadata,
872
+ retry_policy: @config.retry_policy
873
+
874
+ @cloud_tasks_stub.get_iam_policy request, options do |result, operation|
875
+ yield result, operation if block_given?
876
+ return result
877
+ end
878
+ rescue ::Gapic::Rest::Error => e
879
+ raise ::Google::Cloud::Error.from_error(e)
880
+ end
881
+
882
+ ##
883
+ # Sets the access control policy for a {::Google::Cloud::Tasks::V2::Queue Queue}. Replaces any existing
884
+ # policy.
885
+ #
886
+ # Note: The Cloud Console does not check queue-level IAM permissions yet.
887
+ # Project-level permissions are required to use the Cloud Console.
888
+ #
889
+ # Authorization requires the following
890
+ # [Google IAM](https://cloud.google.com/iam) permission on the specified
891
+ # resource parent:
892
+ #
893
+ # * `cloudtasks.queues.setIamPolicy`
894
+ #
895
+ # @overload set_iam_policy(request, options = nil)
896
+ # Pass arguments to `set_iam_policy` via a request object, either of type
897
+ # {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash.
898
+ #
899
+ # @param request [::Google::Iam::V1::SetIamPolicyRequest, ::Hash]
900
+ # A request object representing the call parameters. Required. To specify no
901
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
902
+ # @param options [::Gapic::CallOptions, ::Hash]
903
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
904
+ #
905
+ # @overload set_iam_policy(resource: nil, policy: nil, update_mask: nil)
906
+ # Pass arguments to `set_iam_policy` via keyword arguments. Note that at
907
+ # least one keyword argument is required. To specify no parameters, or to keep all
908
+ # the default parameter values, pass an empty Hash as a request object (see above).
909
+ #
910
+ # @param resource [::String]
911
+ # REQUIRED: The resource for which the policy is being specified.
912
+ # See the operation documentation for the appropriate value for this field.
913
+ # @param policy [::Google::Iam::V1::Policy, ::Hash]
914
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
915
+ # the policy is limited to a few 10s of KB. An empty policy is a
916
+ # valid policy but certain Cloud Platform services (such as Projects)
917
+ # might reject them.
918
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
919
+ # OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
920
+ # the fields in the mask will be modified. If no mask is provided, the
921
+ # following default mask is used:
922
+ #
923
+ # `paths: "bindings, etag"`
924
+ # @yield [result, operation] Access the result along with the TransportOperation object
925
+ # @yieldparam result [::Google::Iam::V1::Policy]
926
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
927
+ #
928
+ # @return [::Google::Iam::V1::Policy]
929
+ #
930
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
931
+ def set_iam_policy request, options = nil
932
+ raise ::ArgumentError, "request must be provided" if request.nil?
933
+
934
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest
935
+
936
+ # Converts hash and nil to an options object
937
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
938
+
939
+ # Customize the options with defaults
940
+ call_metadata = @config.rpcs.set_iam_policy.metadata.to_h
941
+
942
+ # Set x-goog-api-client and x-goog-user-project headers
943
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
944
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
945
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
946
+ transports_version_send: [:rest]
947
+
948
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
949
+
950
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
951
+ metadata: call_metadata,
952
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
953
+
954
+ options.apply_defaults timeout: @config.timeout,
955
+ metadata: @config.metadata,
956
+ retry_policy: @config.retry_policy
957
+
958
+ @cloud_tasks_stub.set_iam_policy request, options do |result, operation|
959
+ yield result, operation if block_given?
960
+ return result
961
+ end
962
+ rescue ::Gapic::Rest::Error => e
963
+ raise ::Google::Cloud::Error.from_error(e)
964
+ end
965
+
966
+ ##
967
+ # Returns permissions that a caller has on a {::Google::Cloud::Tasks::V2::Queue Queue}.
968
+ # If the resource does not exist, this will return an empty set of
969
+ # permissions, not a [NOT_FOUND][google.rpc.Code.NOT_FOUND] error.
970
+ #
971
+ # Note: This operation is designed to be used for building permission-aware
972
+ # UIs and command-line tools, not for authorization checking. This operation
973
+ # may "fail open" without warning.
974
+ #
975
+ # @overload test_iam_permissions(request, options = nil)
976
+ # Pass arguments to `test_iam_permissions` via a request object, either of type
977
+ # {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash.
978
+ #
979
+ # @param request [::Google::Iam::V1::TestIamPermissionsRequest, ::Hash]
980
+ # A request object representing the call parameters. Required. To specify no
981
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
982
+ # @param options [::Gapic::CallOptions, ::Hash]
983
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
984
+ #
985
+ # @overload test_iam_permissions(resource: nil, permissions: nil)
986
+ # Pass arguments to `test_iam_permissions` via keyword arguments. Note that at
987
+ # least one keyword argument is required. To specify no parameters, or to keep all
988
+ # the default parameter values, pass an empty Hash as a request object (see above).
989
+ #
990
+ # @param resource [::String]
991
+ # REQUIRED: The resource for which the policy detail is being requested.
992
+ # See the operation documentation for the appropriate value for this field.
993
+ # @param permissions [::Array<::String>]
994
+ # The set of permissions to check for the `resource`. Permissions with
995
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
996
+ # information see
997
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
998
+ # @yield [result, operation] Access the result along with the TransportOperation object
999
+ # @yieldparam result [::Google::Iam::V1::TestIamPermissionsResponse]
1000
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1001
+ #
1002
+ # @return [::Google::Iam::V1::TestIamPermissionsResponse]
1003
+ #
1004
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1005
+ def test_iam_permissions request, options = nil
1006
+ raise ::ArgumentError, "request must be provided" if request.nil?
1007
+
1008
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest
1009
+
1010
+ # Converts hash and nil to an options object
1011
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1012
+
1013
+ # Customize the options with defaults
1014
+ call_metadata = @config.rpcs.test_iam_permissions.metadata.to_h
1015
+
1016
+ # Set x-goog-api-client and x-goog-user-project headers
1017
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1018
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1019
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
1020
+ transports_version_send: [:rest]
1021
+
1022
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1023
+
1024
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
1025
+ metadata: call_metadata,
1026
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
1027
+
1028
+ options.apply_defaults timeout: @config.timeout,
1029
+ metadata: @config.metadata,
1030
+ retry_policy: @config.retry_policy
1031
+
1032
+ @cloud_tasks_stub.test_iam_permissions request, options do |result, operation|
1033
+ yield result, operation if block_given?
1034
+ return result
1035
+ end
1036
+ rescue ::Gapic::Rest::Error => e
1037
+ raise ::Google::Cloud::Error.from_error(e)
1038
+ end
1039
+
1040
+ ##
1041
+ # Lists the tasks in a queue.
1042
+ #
1043
+ # By default, only the {::Google::Cloud::Tasks::V2::Task::View::BASIC BASIC} view is retrieved
1044
+ # due to performance considerations;
1045
+ # {::Google::Cloud::Tasks::V2::ListTasksRequest#response_view response_view} controls the
1046
+ # subset of information which is returned.
1047
+ #
1048
+ # The tasks may be returned in any order. The ordering may change at any
1049
+ # time.
1050
+ #
1051
+ # @overload list_tasks(request, options = nil)
1052
+ # Pass arguments to `list_tasks` via a request object, either of type
1053
+ # {::Google::Cloud::Tasks::V2::ListTasksRequest} or an equivalent Hash.
1054
+ #
1055
+ # @param request [::Google::Cloud::Tasks::V2::ListTasksRequest, ::Hash]
1056
+ # A request object representing the call parameters. Required. To specify no
1057
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1058
+ # @param options [::Gapic::CallOptions, ::Hash]
1059
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1060
+ #
1061
+ # @overload list_tasks(parent: nil, response_view: nil, page_size: nil, page_token: nil)
1062
+ # Pass arguments to `list_tasks` via keyword arguments. Note that at
1063
+ # least one keyword argument is required. To specify no parameters, or to keep all
1064
+ # the default parameter values, pass an empty Hash as a request object (see above).
1065
+ #
1066
+ # @param parent [::String]
1067
+ # Required. The queue name. For example:
1068
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1069
+ # @param response_view [::Google::Cloud::Tasks::V2::Task::View]
1070
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2::Task Task} will be
1071
+ # returned.
1072
+ #
1073
+ # By default response_view is {::Google::Cloud::Tasks::V2::Task::View::BASIC BASIC}; not all
1074
+ # information is retrieved by default because some data, such as
1075
+ # payloads, might be desirable to return only when needed because
1076
+ # of its large size or because of the sensitivity of data that it
1077
+ # contains.
1078
+ #
1079
+ # Authorization for {::Google::Cloud::Tasks::V2::Task::View::FULL FULL} requires
1080
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1081
+ # permission on the {::Google::Cloud::Tasks::V2::Task Task} resource.
1082
+ # @param page_size [::Integer]
1083
+ # Maximum page size.
1084
+ #
1085
+ # Fewer tasks than requested might be returned, even if more tasks exist; use
1086
+ # {::Google::Cloud::Tasks::V2::ListTasksResponse#next_page_token next_page_token} in the response to
1087
+ # determine if more tasks exist.
1088
+ #
1089
+ # The maximum page size is 1000. If unspecified, the page size will be the
1090
+ # maximum.
1091
+ # @param page_token [::String]
1092
+ # A token identifying the page of results to return.
1093
+ #
1094
+ # To request the first page results, page_token must be empty. To
1095
+ # request the next page of results, page_token must be the value of
1096
+ # {::Google::Cloud::Tasks::V2::ListTasksResponse#next_page_token next_page_token} returned
1097
+ # from the previous call to {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client#list_tasks ListTasks}
1098
+ # method.
1099
+ #
1100
+ # The page token is valid for only 2 hours.
1101
+ # @yield [result, operation] Access the result along with the TransportOperation object
1102
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Tasks::V2::Task>]
1103
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1104
+ #
1105
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Tasks::V2::Task>]
1106
+ #
1107
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1108
+ def list_tasks request, options = nil
1109
+ raise ::ArgumentError, "request must be provided" if request.nil?
1110
+
1111
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::ListTasksRequest
1112
+
1113
+ # Converts hash and nil to an options object
1114
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1115
+
1116
+ # Customize the options with defaults
1117
+ call_metadata = @config.rpcs.list_tasks.metadata.to_h
1118
+
1119
+ # Set x-goog-api-client and x-goog-user-project headers
1120
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1121
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1122
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
1123
+ transports_version_send: [:rest]
1124
+
1125
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1126
+
1127
+ options.apply_defaults timeout: @config.rpcs.list_tasks.timeout,
1128
+ metadata: call_metadata,
1129
+ retry_policy: @config.rpcs.list_tasks.retry_policy
1130
+
1131
+ options.apply_defaults timeout: @config.timeout,
1132
+ metadata: @config.metadata,
1133
+ retry_policy: @config.retry_policy
1134
+
1135
+ @cloud_tasks_stub.list_tasks request, options do |result, operation|
1136
+ result = ::Gapic::Rest::PagedEnumerable.new @cloud_tasks_stub, :list_tasks, "tasks", request, result, options
1137
+ yield result, operation if block_given?
1138
+ return result
1139
+ end
1140
+ rescue ::Gapic::Rest::Error => e
1141
+ raise ::Google::Cloud::Error.from_error(e)
1142
+ end
1143
+
1144
+ ##
1145
+ # Gets a task.
1146
+ #
1147
+ # @overload get_task(request, options = nil)
1148
+ # Pass arguments to `get_task` via a request object, either of type
1149
+ # {::Google::Cloud::Tasks::V2::GetTaskRequest} or an equivalent Hash.
1150
+ #
1151
+ # @param request [::Google::Cloud::Tasks::V2::GetTaskRequest, ::Hash]
1152
+ # A request object representing the call parameters. Required. To specify no
1153
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1154
+ # @param options [::Gapic::CallOptions, ::Hash]
1155
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1156
+ #
1157
+ # @overload get_task(name: nil, response_view: nil)
1158
+ # Pass arguments to `get_task` via keyword arguments. Note that at
1159
+ # least one keyword argument is required. To specify no parameters, or to keep all
1160
+ # the default parameter values, pass an empty Hash as a request object (see above).
1161
+ #
1162
+ # @param name [::String]
1163
+ # Required. The task name. For example:
1164
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1165
+ # @param response_view [::Google::Cloud::Tasks::V2::Task::View]
1166
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2::Task Task} will be
1167
+ # returned.
1168
+ #
1169
+ # By default response_view is {::Google::Cloud::Tasks::V2::Task::View::BASIC BASIC}; not all
1170
+ # information is retrieved by default because some data, such as
1171
+ # payloads, might be desirable to return only when needed because
1172
+ # of its large size or because of the sensitivity of data that it
1173
+ # contains.
1174
+ #
1175
+ # Authorization for {::Google::Cloud::Tasks::V2::Task::View::FULL FULL} requires
1176
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1177
+ # permission on the {::Google::Cloud::Tasks::V2::Task Task} resource.
1178
+ # @yield [result, operation] Access the result along with the TransportOperation object
1179
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Task]
1180
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1181
+ #
1182
+ # @return [::Google::Cloud::Tasks::V2::Task]
1183
+ #
1184
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1185
+ def get_task request, options = nil
1186
+ raise ::ArgumentError, "request must be provided" if request.nil?
1187
+
1188
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::GetTaskRequest
1189
+
1190
+ # Converts hash and nil to an options object
1191
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1192
+
1193
+ # Customize the options with defaults
1194
+ call_metadata = @config.rpcs.get_task.metadata.to_h
1195
+
1196
+ # Set x-goog-api-client and x-goog-user-project headers
1197
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1198
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1199
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
1200
+ transports_version_send: [:rest]
1201
+
1202
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1203
+
1204
+ options.apply_defaults timeout: @config.rpcs.get_task.timeout,
1205
+ metadata: call_metadata,
1206
+ retry_policy: @config.rpcs.get_task.retry_policy
1207
+
1208
+ options.apply_defaults timeout: @config.timeout,
1209
+ metadata: @config.metadata,
1210
+ retry_policy: @config.retry_policy
1211
+
1212
+ @cloud_tasks_stub.get_task request, options do |result, operation|
1213
+ yield result, operation if block_given?
1214
+ return result
1215
+ end
1216
+ rescue ::Gapic::Rest::Error => e
1217
+ raise ::Google::Cloud::Error.from_error(e)
1218
+ end
1219
+
1220
+ ##
1221
+ # Creates a task and adds it to a queue.
1222
+ #
1223
+ # Tasks cannot be updated after creation; there is no UpdateTask command.
1224
+ #
1225
+ # * The maximum task size is 100KB.
1226
+ #
1227
+ # @overload create_task(request, options = nil)
1228
+ # Pass arguments to `create_task` via a request object, either of type
1229
+ # {::Google::Cloud::Tasks::V2::CreateTaskRequest} or an equivalent Hash.
1230
+ #
1231
+ # @param request [::Google::Cloud::Tasks::V2::CreateTaskRequest, ::Hash]
1232
+ # A request object representing the call parameters. Required. To specify no
1233
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1234
+ # @param options [::Gapic::CallOptions, ::Hash]
1235
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1236
+ #
1237
+ # @overload create_task(parent: nil, task: nil, response_view: nil)
1238
+ # Pass arguments to `create_task` via keyword arguments. Note that at
1239
+ # least one keyword argument is required. To specify no parameters, or to keep all
1240
+ # the default parameter values, pass an empty Hash as a request object (see above).
1241
+ #
1242
+ # @param parent [::String]
1243
+ # Required. The queue name. For example:
1244
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1245
+ #
1246
+ # The queue must already exist.
1247
+ # @param task [::Google::Cloud::Tasks::V2::Task, ::Hash]
1248
+ # Required. The task to add.
1249
+ #
1250
+ # Task names have the following format:
1251
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`.
1252
+ # The user can optionally specify a task {::Google::Cloud::Tasks::V2::Task#name name}. If a
1253
+ # name is not specified then the system will generate a random
1254
+ # unique task id, which will be set in the task returned in the
1255
+ # {::Google::Cloud::Tasks::V2::Task#name response}.
1256
+ #
1257
+ # If {::Google::Cloud::Tasks::V2::Task#schedule_time schedule_time} is not set or is in the
1258
+ # past then Cloud Tasks will set it to the current time.
1259
+ #
1260
+ # Task De-duplication:
1261
+ #
1262
+ # Explicitly specifying a task ID enables task de-duplication. If
1263
+ # a task's ID is identical to that of an existing task or a task
1264
+ # that was deleted or executed recently then the call will fail
1265
+ # with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS].
1266
+ # If the task's queue was created using Cloud Tasks, then another task with
1267
+ # the same name can't be created for ~1hour after the original task was
1268
+ # deleted or executed. If the task's queue was created using queue.yaml or
1269
+ # queue.xml, then another task with the same name can't be created
1270
+ # for ~9days after the original task was deleted or executed.
1271
+ #
1272
+ # Because there is an extra lookup cost to identify duplicate task
1273
+ # names, these {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client#create_task CreateTask} calls have significantly
1274
+ # increased latency. Using hashed strings for the task id or for
1275
+ # the prefix of the task id is recommended. Choosing task ids that
1276
+ # are sequential or have sequential prefixes, for example using a
1277
+ # timestamp, causes an increase in latency and error rates in all
1278
+ # task commands. The infrastructure relies on an approximately
1279
+ # uniform distribution of task ids to store and serve tasks
1280
+ # efficiently.
1281
+ # @param response_view [::Google::Cloud::Tasks::V2::Task::View]
1282
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2::Task Task} will be
1283
+ # returned.
1284
+ #
1285
+ # By default response_view is {::Google::Cloud::Tasks::V2::Task::View::BASIC BASIC}; not all
1286
+ # information is retrieved by default because some data, such as
1287
+ # payloads, might be desirable to return only when needed because
1288
+ # of its large size or because of the sensitivity of data that it
1289
+ # contains.
1290
+ #
1291
+ # Authorization for {::Google::Cloud::Tasks::V2::Task::View::FULL FULL} requires
1292
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1293
+ # permission on the {::Google::Cloud::Tasks::V2::Task Task} resource.
1294
+ # @yield [result, operation] Access the result along with the TransportOperation object
1295
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Task]
1296
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1297
+ #
1298
+ # @return [::Google::Cloud::Tasks::V2::Task]
1299
+ #
1300
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1301
+ def create_task request, options = nil
1302
+ raise ::ArgumentError, "request must be provided" if request.nil?
1303
+
1304
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::CreateTaskRequest
1305
+
1306
+ # Converts hash and nil to an options object
1307
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1308
+
1309
+ # Customize the options with defaults
1310
+ call_metadata = @config.rpcs.create_task.metadata.to_h
1311
+
1312
+ # Set x-goog-api-client and x-goog-user-project headers
1313
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1314
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1315
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
1316
+ transports_version_send: [:rest]
1317
+
1318
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1319
+
1320
+ options.apply_defaults timeout: @config.rpcs.create_task.timeout,
1321
+ metadata: call_metadata,
1322
+ retry_policy: @config.rpcs.create_task.retry_policy
1323
+
1324
+ options.apply_defaults timeout: @config.timeout,
1325
+ metadata: @config.metadata,
1326
+ retry_policy: @config.retry_policy
1327
+
1328
+ @cloud_tasks_stub.create_task request, options do |result, operation|
1329
+ yield result, operation if block_given?
1330
+ return result
1331
+ end
1332
+ rescue ::Gapic::Rest::Error => e
1333
+ raise ::Google::Cloud::Error.from_error(e)
1334
+ end
1335
+
1336
+ ##
1337
+ # Deletes a task.
1338
+ #
1339
+ # A task can be deleted if it is scheduled or dispatched. A task
1340
+ # cannot be deleted if it has executed successfully or permanently
1341
+ # failed.
1342
+ #
1343
+ # @overload delete_task(request, options = nil)
1344
+ # Pass arguments to `delete_task` via a request object, either of type
1345
+ # {::Google::Cloud::Tasks::V2::DeleteTaskRequest} or an equivalent Hash.
1346
+ #
1347
+ # @param request [::Google::Cloud::Tasks::V2::DeleteTaskRequest, ::Hash]
1348
+ # A request object representing the call parameters. Required. To specify no
1349
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1350
+ # @param options [::Gapic::CallOptions, ::Hash]
1351
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1352
+ #
1353
+ # @overload delete_task(name: nil)
1354
+ # Pass arguments to `delete_task` via keyword arguments. Note that at
1355
+ # least one keyword argument is required. To specify no parameters, or to keep all
1356
+ # the default parameter values, pass an empty Hash as a request object (see above).
1357
+ #
1358
+ # @param name [::String]
1359
+ # Required. The task name. For example:
1360
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1361
+ # @yield [result, operation] Access the result along with the TransportOperation object
1362
+ # @yieldparam result [::Google::Protobuf::Empty]
1363
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1364
+ #
1365
+ # @return [::Google::Protobuf::Empty]
1366
+ #
1367
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1368
+ def delete_task request, options = nil
1369
+ raise ::ArgumentError, "request must be provided" if request.nil?
1370
+
1371
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::DeleteTaskRequest
1372
+
1373
+ # Converts hash and nil to an options object
1374
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1375
+
1376
+ # Customize the options with defaults
1377
+ call_metadata = @config.rpcs.delete_task.metadata.to_h
1378
+
1379
+ # Set x-goog-api-client and x-goog-user-project headers
1380
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1381
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1382
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
1383
+ transports_version_send: [:rest]
1384
+
1385
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1386
+
1387
+ options.apply_defaults timeout: @config.rpcs.delete_task.timeout,
1388
+ metadata: call_metadata,
1389
+ retry_policy: @config.rpcs.delete_task.retry_policy
1390
+
1391
+ options.apply_defaults timeout: @config.timeout,
1392
+ metadata: @config.metadata,
1393
+ retry_policy: @config.retry_policy
1394
+
1395
+ @cloud_tasks_stub.delete_task request, options do |result, operation|
1396
+ yield result, operation if block_given?
1397
+ return result
1398
+ end
1399
+ rescue ::Gapic::Rest::Error => e
1400
+ raise ::Google::Cloud::Error.from_error(e)
1401
+ end
1402
+
1403
+ ##
1404
+ # Forces a task to run now.
1405
+ #
1406
+ # When this method is called, Cloud Tasks will dispatch the task, even if
1407
+ # the task is already running, the queue has reached its {::Google::Cloud::Tasks::V2::RateLimits RateLimits} or
1408
+ # is {::Google::Cloud::Tasks::V2::Queue::State::PAUSED PAUSED}.
1409
+ #
1410
+ # This command is meant to be used for manual debugging. For
1411
+ # example, {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client#run_task RunTask} can be used to retry a failed
1412
+ # task after a fix has been made or to manually force a task to be
1413
+ # dispatched now.
1414
+ #
1415
+ # The dispatched task is returned. That is, the task that is returned
1416
+ # contains the [status][Task.status] after the task is dispatched but
1417
+ # before the task is received by its target.
1418
+ #
1419
+ # If Cloud Tasks receives a successful response from the task's
1420
+ # target, then the task will be deleted; otherwise the task's
1421
+ # {::Google::Cloud::Tasks::V2::Task#schedule_time schedule_time} will be reset to the time that
1422
+ # {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client#run_task RunTask} was called plus the retry delay specified
1423
+ # in the queue's {::Google::Cloud::Tasks::V2::RetryConfig RetryConfig}.
1424
+ #
1425
+ # {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client#run_task RunTask} returns
1426
+ # [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a
1427
+ # task that has already succeeded or permanently failed.
1428
+ #
1429
+ # @overload run_task(request, options = nil)
1430
+ # Pass arguments to `run_task` via a request object, either of type
1431
+ # {::Google::Cloud::Tasks::V2::RunTaskRequest} or an equivalent Hash.
1432
+ #
1433
+ # @param request [::Google::Cloud::Tasks::V2::RunTaskRequest, ::Hash]
1434
+ # A request object representing the call parameters. Required. To specify no
1435
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1436
+ # @param options [::Gapic::CallOptions, ::Hash]
1437
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1438
+ #
1439
+ # @overload run_task(name: nil, response_view: nil)
1440
+ # Pass arguments to `run_task` via keyword arguments. Note that at
1441
+ # least one keyword argument is required. To specify no parameters, or to keep all
1442
+ # the default parameter values, pass an empty Hash as a request object (see above).
1443
+ #
1444
+ # @param name [::String]
1445
+ # Required. The task name. For example:
1446
+ # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1447
+ # @param response_view [::Google::Cloud::Tasks::V2::Task::View]
1448
+ # The response_view specifies which subset of the {::Google::Cloud::Tasks::V2::Task Task} will be
1449
+ # returned.
1450
+ #
1451
+ # By default response_view is {::Google::Cloud::Tasks::V2::Task::View::BASIC BASIC}; not all
1452
+ # information is retrieved by default because some data, such as
1453
+ # payloads, might be desirable to return only when needed because
1454
+ # of its large size or because of the sensitivity of data that it
1455
+ # contains.
1456
+ #
1457
+ # Authorization for {::Google::Cloud::Tasks::V2::Task::View::FULL FULL} requires
1458
+ # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1459
+ # permission on the {::Google::Cloud::Tasks::V2::Task Task} resource.
1460
+ # @yield [result, operation] Access the result along with the TransportOperation object
1461
+ # @yieldparam result [::Google::Cloud::Tasks::V2::Task]
1462
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1463
+ #
1464
+ # @return [::Google::Cloud::Tasks::V2::Task]
1465
+ #
1466
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1467
+ def run_task request, options = nil
1468
+ raise ::ArgumentError, "request must be provided" if request.nil?
1469
+
1470
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::RunTaskRequest
1471
+
1472
+ # Converts hash and nil to an options object
1473
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1474
+
1475
+ # Customize the options with defaults
1476
+ call_metadata = @config.rpcs.run_task.metadata.to_h
1477
+
1478
+ # Set x-goog-api-client and x-goog-user-project headers
1479
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1480
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1481
+ gapic_version: ::Google::Cloud::Tasks::V2::VERSION,
1482
+ transports_version_send: [:rest]
1483
+
1484
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1485
+
1486
+ options.apply_defaults timeout: @config.rpcs.run_task.timeout,
1487
+ metadata: call_metadata,
1488
+ retry_policy: @config.rpcs.run_task.retry_policy
1489
+
1490
+ options.apply_defaults timeout: @config.timeout,
1491
+ metadata: @config.metadata,
1492
+ retry_policy: @config.retry_policy
1493
+
1494
+ @cloud_tasks_stub.run_task request, options do |result, operation|
1495
+ yield result, operation if block_given?
1496
+ return result
1497
+ end
1498
+ rescue ::Gapic::Rest::Error => e
1499
+ raise ::Google::Cloud::Error.from_error(e)
1500
+ end
1501
+
1502
+ ##
1503
+ # Configuration class for the CloudTasks REST API.
1504
+ #
1505
+ # This class represents the configuration for CloudTasks REST,
1506
+ # providing control over timeouts, retry behavior, logging, transport
1507
+ # parameters, and other low-level controls. Certain parameters can also be
1508
+ # applied individually to specific RPCs. See
1509
+ # {::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client::Configuration::Rpcs}
1510
+ # for a list of RPCs that can be configured independently.
1511
+ #
1512
+ # Configuration can be applied globally to all clients, or to a single client
1513
+ # on construction.
1514
+ #
1515
+ # @example
1516
+ #
1517
+ # # Modify the global config, setting the timeout for
1518
+ # # list_queues to 20 seconds,
1519
+ # # and all remaining timeouts to 10 seconds.
1520
+ # ::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client.configure do |config|
1521
+ # config.timeout = 10.0
1522
+ # config.rpcs.list_queues.timeout = 20.0
1523
+ # end
1524
+ #
1525
+ # # Apply the above configuration only to a new client.
1526
+ # client = ::Google::Cloud::Tasks::V2::CloudTasks::Rest::Client.new do |config|
1527
+ # config.timeout = 10.0
1528
+ # config.rpcs.list_queues.timeout = 20.0
1529
+ # end
1530
+ #
1531
+ # @!attribute [rw] endpoint
1532
+ # The hostname or hostname:port of the service endpoint.
1533
+ # Defaults to `"cloudtasks.googleapis.com"`.
1534
+ # @return [::String]
1535
+ # @!attribute [rw] credentials
1536
+ # Credentials to send with calls. You may provide any of the following types:
1537
+ # * (`String`) The path to a service account key file in JSON format
1538
+ # * (`Hash`) A service account key as a Hash
1539
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1540
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
1541
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1542
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
1543
+ # * (`nil`) indicating no credentials
1544
+ # @return [::Object]
1545
+ # @!attribute [rw] scope
1546
+ # The OAuth scopes
1547
+ # @return [::Array<::String>]
1548
+ # @!attribute [rw] lib_name
1549
+ # The library name as recorded in instrumentation and logging
1550
+ # @return [::String]
1551
+ # @!attribute [rw] lib_version
1552
+ # The library version as recorded in instrumentation and logging
1553
+ # @return [::String]
1554
+ # @!attribute [rw] timeout
1555
+ # The call timeout in seconds.
1556
+ # @return [::Numeric]
1557
+ # @!attribute [rw] metadata
1558
+ # Additional headers to be sent with the call.
1559
+ # @return [::Hash{::Symbol=>::String}]
1560
+ # @!attribute [rw] retry_policy
1561
+ # The retry policy. The value is a hash with the following keys:
1562
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1563
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1564
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1565
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1566
+ # trigger a retry.
1567
+ # @return [::Hash]
1568
+ # @!attribute [rw] quota_project
1569
+ # A separate project against which to charge quota.
1570
+ # @return [::String]
1571
+ #
1572
+ class Configuration
1573
+ extend ::Gapic::Config
1574
+
1575
+ config_attr :endpoint, "cloudtasks.googleapis.com", ::String
1576
+ config_attr :credentials, nil do |value|
1577
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1578
+ allowed.any? { |klass| klass === value }
1579
+ end
1580
+ config_attr :scope, nil, ::String, ::Array, nil
1581
+ config_attr :lib_name, nil, ::String, nil
1582
+ config_attr :lib_version, nil, ::String, nil
1583
+ config_attr :timeout, nil, ::Numeric, nil
1584
+ config_attr :metadata, nil, ::Hash, nil
1585
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1586
+ config_attr :quota_project, nil, ::String, nil
1587
+
1588
+ # @private
1589
+ def initialize parent_config = nil
1590
+ @parent_config = parent_config unless parent_config.nil?
1591
+
1592
+ yield self if block_given?
1593
+ end
1594
+
1595
+ ##
1596
+ # Configurations for individual RPCs
1597
+ # @return [Rpcs]
1598
+ #
1599
+ def rpcs
1600
+ @rpcs ||= begin
1601
+ parent_rpcs = nil
1602
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1603
+ Rpcs.new parent_rpcs
1604
+ end
1605
+ end
1606
+
1607
+ ##
1608
+ # Configuration RPC class for the CloudTasks API.
1609
+ #
1610
+ # Includes fields providing the configuration for each RPC in this service.
1611
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1612
+ # the following configuration fields:
1613
+ #
1614
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1615
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
1616
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1617
+ # include the following keys:
1618
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1619
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1620
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1621
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1622
+ # trigger a retry.
1623
+ #
1624
+ class Rpcs
1625
+ ##
1626
+ # RPC-specific configuration for `list_queues`
1627
+ # @return [::Gapic::Config::Method]
1628
+ #
1629
+ attr_reader :list_queues
1630
+ ##
1631
+ # RPC-specific configuration for `get_queue`
1632
+ # @return [::Gapic::Config::Method]
1633
+ #
1634
+ attr_reader :get_queue
1635
+ ##
1636
+ # RPC-specific configuration for `create_queue`
1637
+ # @return [::Gapic::Config::Method]
1638
+ #
1639
+ attr_reader :create_queue
1640
+ ##
1641
+ # RPC-specific configuration for `update_queue`
1642
+ # @return [::Gapic::Config::Method]
1643
+ #
1644
+ attr_reader :update_queue
1645
+ ##
1646
+ # RPC-specific configuration for `delete_queue`
1647
+ # @return [::Gapic::Config::Method]
1648
+ #
1649
+ attr_reader :delete_queue
1650
+ ##
1651
+ # RPC-specific configuration for `purge_queue`
1652
+ # @return [::Gapic::Config::Method]
1653
+ #
1654
+ attr_reader :purge_queue
1655
+ ##
1656
+ # RPC-specific configuration for `pause_queue`
1657
+ # @return [::Gapic::Config::Method]
1658
+ #
1659
+ attr_reader :pause_queue
1660
+ ##
1661
+ # RPC-specific configuration for `resume_queue`
1662
+ # @return [::Gapic::Config::Method]
1663
+ #
1664
+ attr_reader :resume_queue
1665
+ ##
1666
+ # RPC-specific configuration for `get_iam_policy`
1667
+ # @return [::Gapic::Config::Method]
1668
+ #
1669
+ attr_reader :get_iam_policy
1670
+ ##
1671
+ # RPC-specific configuration for `set_iam_policy`
1672
+ # @return [::Gapic::Config::Method]
1673
+ #
1674
+ attr_reader :set_iam_policy
1675
+ ##
1676
+ # RPC-specific configuration for `test_iam_permissions`
1677
+ # @return [::Gapic::Config::Method]
1678
+ #
1679
+ attr_reader :test_iam_permissions
1680
+ ##
1681
+ # RPC-specific configuration for `list_tasks`
1682
+ # @return [::Gapic::Config::Method]
1683
+ #
1684
+ attr_reader :list_tasks
1685
+ ##
1686
+ # RPC-specific configuration for `get_task`
1687
+ # @return [::Gapic::Config::Method]
1688
+ #
1689
+ attr_reader :get_task
1690
+ ##
1691
+ # RPC-specific configuration for `create_task`
1692
+ # @return [::Gapic::Config::Method]
1693
+ #
1694
+ attr_reader :create_task
1695
+ ##
1696
+ # RPC-specific configuration for `delete_task`
1697
+ # @return [::Gapic::Config::Method]
1698
+ #
1699
+ attr_reader :delete_task
1700
+ ##
1701
+ # RPC-specific configuration for `run_task`
1702
+ # @return [::Gapic::Config::Method]
1703
+ #
1704
+ attr_reader :run_task
1705
+
1706
+ # @private
1707
+ def initialize parent_rpcs = nil
1708
+ list_queues_config = parent_rpcs.list_queues if parent_rpcs.respond_to? :list_queues
1709
+ @list_queues = ::Gapic::Config::Method.new list_queues_config
1710
+ get_queue_config = parent_rpcs.get_queue if parent_rpcs.respond_to? :get_queue
1711
+ @get_queue = ::Gapic::Config::Method.new get_queue_config
1712
+ create_queue_config = parent_rpcs.create_queue if parent_rpcs.respond_to? :create_queue
1713
+ @create_queue = ::Gapic::Config::Method.new create_queue_config
1714
+ update_queue_config = parent_rpcs.update_queue if parent_rpcs.respond_to? :update_queue
1715
+ @update_queue = ::Gapic::Config::Method.new update_queue_config
1716
+ delete_queue_config = parent_rpcs.delete_queue if parent_rpcs.respond_to? :delete_queue
1717
+ @delete_queue = ::Gapic::Config::Method.new delete_queue_config
1718
+ purge_queue_config = parent_rpcs.purge_queue if parent_rpcs.respond_to? :purge_queue
1719
+ @purge_queue = ::Gapic::Config::Method.new purge_queue_config
1720
+ pause_queue_config = parent_rpcs.pause_queue if parent_rpcs.respond_to? :pause_queue
1721
+ @pause_queue = ::Gapic::Config::Method.new pause_queue_config
1722
+ resume_queue_config = parent_rpcs.resume_queue if parent_rpcs.respond_to? :resume_queue
1723
+ @resume_queue = ::Gapic::Config::Method.new resume_queue_config
1724
+ get_iam_policy_config = parent_rpcs.get_iam_policy if parent_rpcs.respond_to? :get_iam_policy
1725
+ @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
1726
+ set_iam_policy_config = parent_rpcs.set_iam_policy if parent_rpcs.respond_to? :set_iam_policy
1727
+ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
1728
+ test_iam_permissions_config = parent_rpcs.test_iam_permissions if parent_rpcs.respond_to? :test_iam_permissions
1729
+ @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
1730
+ list_tasks_config = parent_rpcs.list_tasks if parent_rpcs.respond_to? :list_tasks
1731
+ @list_tasks = ::Gapic::Config::Method.new list_tasks_config
1732
+ get_task_config = parent_rpcs.get_task if parent_rpcs.respond_to? :get_task
1733
+ @get_task = ::Gapic::Config::Method.new get_task_config
1734
+ create_task_config = parent_rpcs.create_task if parent_rpcs.respond_to? :create_task
1735
+ @create_task = ::Gapic::Config::Method.new create_task_config
1736
+ delete_task_config = parent_rpcs.delete_task if parent_rpcs.respond_to? :delete_task
1737
+ @delete_task = ::Gapic::Config::Method.new delete_task_config
1738
+ run_task_config = parent_rpcs.run_task if parent_rpcs.respond_to? :run_task
1739
+ @run_task = ::Gapic::Config::Method.new run_task_config
1740
+
1741
+ yield self if block_given?
1742
+ end
1743
+ end
1744
+ end
1745
+ end
1746
+ end
1747
+ end
1748
+ end
1749
+ end
1750
+ end
1751
+ end