Class: Google::Cloud::Tasks::V2::CloudTasks::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/tasks/v2/cloud_tasks/client.rb

Overview

Client for the CloudTasks service.

Cloud Tasks allows developers to manage the execution of background work in their applications.

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#location_path, #queue_path, #task_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new CloudTasks client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Tasks::V2::CloudTasks::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the CloudTasks client.

Yield Parameters:



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 179

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/tasks/v2/cloudtasks_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @cloud_tasks_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Tasks::V2::CloudTasks::Stub,
    credentials: credentials,
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool
  )

  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @cloud_tasks_stub.endpoint
    config.universe_domain = @cloud_tasks_stub.universe_domain
  end
end

Instance Attribute Details

#location_clientGoogle::Cloud::Location::Locations::Client (readonly)

Get the associated client for mix-in of the Locations.

Returns:

  • (Google::Cloud::Location::Locations::Client)


231
232
233
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 231

def location_client
  @location_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the CloudTasks Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all CloudTasks clients
::Google::Cloud::Tasks::V2::CloudTasks::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 61

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Tasks", "V2"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.list_queues.timeout = 20.0
    default_config.rpcs.list_queues.retry_policy = {
      initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_queue.timeout = 20.0
    default_config.rpcs.get_queue.retry_policy = {
      initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.create_queue.timeout = 20.0

    default_config.rpcs.update_queue.timeout = 20.0

    default_config.rpcs.delete_queue.timeout = 20.0
    default_config.rpcs.delete_queue.retry_policy = {
      initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.purge_queue.timeout = 20.0

    default_config.rpcs.pause_queue.timeout = 20.0

    default_config.rpcs.resume_queue.timeout = 20.0

    default_config.rpcs.get_iam_policy.timeout = 20.0
    default_config.rpcs.get_iam_policy.retry_policy = {
      initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.set_iam_policy.timeout = 20.0

    default_config.rpcs.test_iam_permissions.timeout = 20.0
    default_config.rpcs.test_iam_permissions.retry_policy = {
      initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.list_tasks.timeout = 20.0
    default_config.rpcs.list_tasks.retry_policy = {
      initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_task.timeout = 20.0
    default_config.rpcs.get_task.retry_policy = {
      initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.create_task.timeout = 20.0

    default_config.rpcs.delete_task.timeout = 20.0
    default_config.rpcs.delete_task.retry_policy = {
      initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.run_task.timeout = 20.0

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#configure {|config| ... } ⇒ Client::Configuration

Configure the CloudTasks Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



149
150
151
152
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 149

def configure
  yield @config if block_given?
  @config
end

#create_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue #create_queue(parent: nil, queue: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

Creates a queue.

Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.

WARNING: Using this method may have unintended side effects if you are using an App Engine queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::CreateQueueRequest.new

# Call the create_queue method.
result = client.create_queue request

# The returned object is of type Google::Cloud::Tasks::V2::Queue.
p result

Overloads:

  • #create_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to create_queue via a request object, either of type Google::Cloud::Tasks::V2::CreateQueueRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::CreateQueueRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_queue(parent: nil, queue: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to create_queue via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The location name in which the queue will be created. For example: projects/PROJECT_ID/locations/LOCATION_ID

      The list of allowed locations can be obtained by calling Cloud Tasks' implementation of ::Google::Cloud::Location::Locations::Client#list_locations.

    • queue (::Google::Cloud::Tasks::V2::Queue, ::Hash) (defaults to: nil)

      Required. The queue to create.

      [Queue's name][google.cloud.tasks.v2.Queue.name] cannot be the same as an existing queue.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 509

def create_queue request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::CreateQueueRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_queue..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_queue.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_queue.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :create_queue, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_task(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Task #create_task(parent: nil, task: nil, response_view: nil) ⇒ ::Google::Cloud::Tasks::V2::Task

Creates a task and adds it to a queue.

Tasks cannot be updated after creation; there is no UpdateTask command.

  • The maximum task size is 100KB.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::CreateTaskRequest.new

# Call the create_task method.
result = client.create_task request

# The returned object is of type Google::Cloud::Tasks::V2::Task.
p result

Overloads:

  • #create_task(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Task

    Pass arguments to create_task via a request object, either of type Google::Cloud::Tasks::V2::CreateTaskRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::CreateTaskRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_task(parent: nil, task: nil, response_view: nil) ⇒ ::Google::Cloud::Tasks::V2::Task

    Pass arguments to create_task via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID

      The queue must already exist.

    • task (::Google::Cloud::Tasks::V2::Task, ::Hash) (defaults to: nil)

      Required. The task to add.

      Task names have the following format: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID. The user can optionally specify a task name. If a name is not specified then the system will generate a random unique task id, which will be set in the task returned in the response.

      If schedule_time is not set or is in the past then Cloud Tasks will set it to the current time.

      Task De-duplication:

      Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical to that of an existing task or a task that was deleted or executed recently then the call will fail with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS]. If the task's queue was created using Cloud Tasks, then another task with the same name can't be created for ~1hour after the original task was deleted or executed. If the task's queue was created using queue.yaml or queue.xml, then another task with the same name can't be created for ~9days after the original task was deleted or executed.

      Because there is an extra lookup cost to identify duplicate task names, these CreateTask calls have significantly increased latency. Using hashed strings for the task id or for the prefix of the task id is recommended. Choosing task ids that are sequential or have sequential prefixes, for example using a timestamp, causes an increase in latency and error rates in all task commands. The infrastructure relies on an approximately uniform distribution of task ids to store and serve tasks efficiently.

    • response_view (::Google::Cloud::Tasks::V2::Task::View) (defaults to: nil)

      The response_view specifies which subset of the Task will be returned.

      By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

      Authorization for FULL requires cloudtasks.tasks.fullView Google IAM permission on the Task resource.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 1670

def create_task request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::CreateTaskRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_task..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_task.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_task.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :create_task, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_queue(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_queue(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes a queue.

This command will delete the queue even if it has tasks in it.

Note: If you delete a queue, a queue with the same name can't be created for 7 days.

WARNING: Using this method may have unintended side effects if you are using an App Engine queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::DeleteQueueRequest.new

# Call the delete_queue method.
result = client.delete_queue request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_queue(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_queue via a request object, either of type DeleteQueueRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::DeleteQueueRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_queue(name: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_queue via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 716

def delete_queue request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::DeleteQueueRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_queue..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_queue.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_queue.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :delete_queue, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_task(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_task(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes a task.

A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has executed successfully or permanently failed.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::DeleteTaskRequest.new

# Call the delete_task method.
result = client.delete_task request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_task(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_task via a request object, either of type DeleteTaskRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::DeleteTaskRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_task(name: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_task via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The task name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 1760

def delete_task request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::DeleteTaskRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_task..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_task.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_task.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :delete_task, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy #get_iam_policy(resource: nil, options: nil) ⇒ ::Google::Iam::V1::Policy

Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set.

Authorization requires the following Google IAM permission on the specified resource parent:

  • cloudtasks.queues.getIamPolicy

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::GetIamPolicyRequest.new

# Call the get_iam_policy method.
result = client.get_iam_policy request

# The returned object is of type Google::Iam::V1::Policy.
p result

Overloads:

  • #get_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy

    Pass arguments to get_iam_policy via a request object, either of type Iam::V1::GetIamPolicyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Iam::V1::GetIamPolicyRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_iam_policy(resource: nil, options: nil) ⇒ ::Google::Iam::V1::Policy

    Pass arguments to get_iam_policy via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • resource (::String) (defaults to: nil)

      REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

    • options (::Google::Iam::V1::GetPolicyOptions, ::Hash) (defaults to: nil)

      OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 1096

def get_iam_policy request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_iam_policy..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.resource
    header_params["resource"] = request.resource
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_iam_policy.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_iam_policy.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :get_iam_policy, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue #get_queue(name: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

Gets a queue.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::GetQueueRequest.new

# Call the get_queue method.
result = client.get_queue request

# The returned object is of type Google::Cloud::Tasks::V2::Queue.
p result

Overloads:

  • #get_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to get_queue via a request object, either of type GetQueueRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::GetQueueRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_queue(name: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to get_queue via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the queue. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 403

def get_queue request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::GetQueueRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_queue..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_queue.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_queue.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :get_queue, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_task(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Task #get_task(name: nil, response_view: nil) ⇒ ::Google::Cloud::Tasks::V2::Task

Gets a task.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::GetTaskRequest.new

# Call the get_task method.
result = client.get_task request

# The returned object is of type Google::Cloud::Tasks::V2::Task.
p result

Overloads:

  • #get_task(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Task

    Pass arguments to get_task via a request object, either of type GetTaskRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::GetTaskRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_task(name: nil, response_view: nil) ⇒ ::Google::Cloud::Tasks::V2::Task

    Pass arguments to get_task via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The task name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID

    • response_view (::Google::Cloud::Tasks::V2::Task::View) (defaults to: nil)

      The response_view specifies which subset of the Task will be returned.

      By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

      Authorization for FULL requires cloudtasks.tasks.fullView Google IAM permission on the Task resource.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 1531

def get_task request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::GetTaskRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_task..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_task.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_task.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :get_task, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_queues(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2::Queue> #list_queues(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2::Queue>

Lists queues.

Queues are returned in lexicographical order.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::ListQueuesRequest.new

# Call the list_queues method.
result = client.list_queues request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Tasks::V2::Queue.
  p item
end

Overloads:

  • #list_queues(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2::Queue>

    Pass arguments to list_queues via a request object, either of type ListQueuesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::ListQueuesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_queues(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2::Queue>

    Pass arguments to list_queues via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The location name. For example: projects/PROJECT_ID/locations/LOCATION_ID

    • filter (::String) (defaults to: nil)

      filter can be used to specify a subset of queues. Any Queue field can be used as a filter and several operators as supported. For example: <=, <, >=, >, !=, =, :. The filter syntax is the same as described in Stackdriver's Advanced Logs Filters.

      Sample filter "state: PAUSED".

      Note that using filters might cause fewer queues than the requested page_size to be returned.

    • page_size (::Integer) (defaults to: nil)

      Requested page size.

      The maximum page size is 9800. If unspecified, the page size will be the maximum. Fewer queues than requested might be returned, even if more queues exist; use the next_page_token in the response to determine if more queues exist.

    • page_token (::String) (defaults to: nil)

      A token identifying the page of results to return.

      To request the first page results, page_token must be empty. To request the next page of results, page_token must be the value of next_page_token returned from the previous call to ListQueues method. It is an error to switch the value of the filter while iterating through pages.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 316

def list_queues request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::ListQueuesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_queues..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_queues.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_queues.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :list_queues, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @cloud_tasks_stub, :list_queues, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_tasks(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2::Task> #list_tasks(parent: nil, response_view: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2::Task>

Lists the tasks in a queue.

By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned.

The tasks may be returned in any order. The ordering may change at any time.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::ListTasksRequest.new

# Call the list_tasks method.
result = client.list_tasks request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Tasks::V2::Task.
  p item
end

Overloads:

  • #list_tasks(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2::Task>

    Pass arguments to list_tasks via a request object, either of type ListTasksRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::ListTasksRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_tasks(parent: nil, response_view: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2::Task>

    Pass arguments to list_tasks via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID

    • response_view (::Google::Cloud::Tasks::V2::Task::View) (defaults to: nil)

      The response_view specifies which subset of the Task will be returned.

      By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

      Authorization for FULL requires cloudtasks.tasks.fullView Google IAM permission on the Task resource.

    • page_size (::Integer) (defaults to: nil)

      Maximum page size.

      Fewer tasks than requested might be returned, even if more tasks exist; use next_page_token in the response to determine if more tasks exist.

      The maximum page size is 1000. If unspecified, the page size will be the maximum.

    • page_token (::String) (defaults to: nil)

      A token identifying the page of results to return.

      To request the first page results, page_token must be empty. To request the next page of results, page_token must be the value of next_page_token returned from the previous call to ListTasks method.

      The page token is valid for only 2 hours.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 1431

def list_tasks request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::ListTasksRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_tasks..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_tasks.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_tasks.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :list_tasks, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @cloud_tasks_stub, :list_tasks, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#pause_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue #pause_queue(name: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

Pauses the queue.

If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::PauseQueueRequest.new

# Call the pause_queue method.
result = client.pause_queue request

# The returned object is of type Google::Cloud::Tasks::V2::Queue.
p result

Overloads:

  • #pause_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to pause_queue via a request object, either of type PauseQueueRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::PauseQueueRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #pause_queue(name: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to pause_queue via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The queue name. For example: projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 900

def pause_queue request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::PauseQueueRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.pause_queue..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.pause_queue.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.pause_queue.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :pause_queue, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#purge_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue #purge_queue(name: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

Purges a queue by deleting all of its tasks.

All tasks created before this method is called are permanently deleted.

Purge operations can take up to one minute to take effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::PurgeQueueRequest.new

# Call the purge_queue method.
result = client.purge_queue request

# The returned object is of type Google::Cloud::Tasks::V2::Queue.
p result

Overloads:

  • #purge_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to purge_queue via a request object, either of type PurgeQueueRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::PurgeQueueRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #purge_queue(name: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to purge_queue via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The queue name. For example: projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 807

def purge_queue request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::PurgeQueueRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.purge_queue..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.purge_queue.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.purge_queue.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :purge_queue, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#resume_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue #resume_queue(name: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

Resume a queue.

This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING.

WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in Managing Cloud Tasks Scaling Risks.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::ResumeQueueRequest.new

# Call the resume_queue method.
result = client.resume_queue request

# The returned object is of type Google::Cloud::Tasks::V2::Queue.
p result

Overloads:

  • #resume_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to resume_queue via a request object, either of type ResumeQueueRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::ResumeQueueRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #resume_queue(name: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to resume_queue via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The queue name. For example: projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 999

def resume_queue request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::ResumeQueueRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.resume_queue..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.resume_queue.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.resume_queue.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :resume_queue, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#run_task(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Task #run_task(name: nil, response_view: nil) ⇒ ::Google::Cloud::Tasks::V2::Task

Forces a task to run now.

When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED.

This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now.

The dispatched task is returned. That is, the task that is returned contains the [status][Task.status] after the task is dispatched but before the task is received by its target.

If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig.

RunTask returns [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded or permanently failed.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::RunTaskRequest.new

# Call the run_task method.
result = client.run_task request

# The returned object is of type Google::Cloud::Tasks::V2::Task.
p result

Overloads:

  • #run_task(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Task

    Pass arguments to run_task via a request object, either of type RunTaskRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::RunTaskRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #run_task(name: nil, response_view: nil) ⇒ ::Google::Cloud::Tasks::V2::Task

    Pass arguments to run_task via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The task name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID

    • response_view (::Google::Cloud::Tasks::V2::Task::View) (defaults to: nil)

      The response_view specifies which subset of the Task will be returned.

      By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

      Authorization for FULL requires cloudtasks.tasks.fullView Google IAM permission on the Task resource.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 1884

def run_task request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::RunTaskRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.run_task..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.run_task.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.run_task.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :run_task, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy #set_iam_policy(resource: nil, policy: nil, update_mask: nil) ⇒ ::Google::Iam::V1::Policy

Sets the access control policy for a Queue. Replaces any existing policy.

Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console.

Authorization requires the following Google IAM permission on the specified resource parent:

  • cloudtasks.queues.setIamPolicy

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::SetIamPolicyRequest.new

# Call the set_iam_policy method.
result = client.set_iam_policy request

# The returned object is of type Google::Iam::V1::Policy.
p result

Overloads:

  • #set_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy

    Pass arguments to set_iam_policy via a request object, either of type Iam::V1::SetIamPolicyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Iam::V1::SetIamPolicyRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #set_iam_policy(resource: nil, policy: nil, update_mask: nil) ⇒ ::Google::Iam::V1::Policy

    Pass arguments to set_iam_policy via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • resource (::String) (defaults to: nil)

      REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

    • policy (::Google::Iam::V1::Policy, ::Hash) (defaults to: nil)

      REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used:

      paths: "bindings, etag"

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 1203

def set_iam_policy request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.set_iam_policy..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.resource
    header_params["resource"] = request.resource
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.set_iam_policy.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.set_iam_policy.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :set_iam_policy, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#test_iam_permissions(request, options = nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse #test_iam_permissions(resource: nil, permissions: nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse

Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a [NOT_FOUND][google.rpc.Code.NOT_FOUND] error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::TestIamPermissionsRequest.new

# Call the test_iam_permissions method.
result = client.test_iam_permissions request

# The returned object is of type Google::Iam::V1::TestIamPermissionsResponse.
p result

Overloads:

  • #test_iam_permissions(request, options = nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse

    Pass arguments to test_iam_permissions via a request object, either of type Iam::V1::TestIamPermissionsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Iam::V1::TestIamPermissionsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #test_iam_permissions(resource: nil, permissions: nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse

    Pass arguments to test_iam_permissions via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • resource (::String) (defaults to: nil)

      REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

    • permissions (::Array<::String>) (defaults to: nil)

      The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 1301

def test_iam_permissions request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.test_iam_permissions..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.resource
    header_params["resource"] = request.resource
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.test_iam_permissions.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.test_iam_permissions.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


159
160
161
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 159

def universe_domain
  @cloud_tasks_stub.universe_domain
end

#update_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue #update_queue(queue: nil, update_mask: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

Updates a queue.

This method creates the queue if it does not exist and updates the queue if it does exist.

Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.

WARNING: Using this method may have unintended side effects if you are using an App Engine queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.

Examples:

Basic example

require "google/cloud/tasks/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Tasks::V2::CloudTasks::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Tasks::V2::UpdateQueueRequest.new

# Call the update_queue method.
result = client.update_queue request

# The returned object is of type Google::Cloud::Tasks::V2::Queue.
p result

Overloads:

  • #update_queue(request, options = nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to update_queue via a request object, either of type UpdateQueueRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Tasks::V2::UpdateQueueRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_queue(queue: nil, update_mask: nil) ⇒ ::Google::Cloud::Tasks::V2::Queue

    Pass arguments to update_queue via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • queue (::Google::Cloud::Tasks::V2::Queue, ::Hash) (defaults to: nil)

      Required. The queue to create or update.

      The queue's name must be specified.

      Output only fields cannot be modified using UpdateQueue. Any value specified for an output only field will be ignored. The queue's name cannot be changed.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      A mask used to specify which fields of the queue are being updated.

      If empty, then all fields will be updated.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
# File 'lib/google/cloud/tasks/v2/cloud_tasks/client.rb', line 618

def update_queue request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2::UpdateQueueRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_queue..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Tasks::V2::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.queue&.name
    header_params["queue.name"] = request.queue.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_queue.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_queue.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @cloud_tasks_stub.call_rpc :update_queue, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end