class Google::Cloud::Tasks::V2beta2::CloudTasks::Client
Client
for the CloudTasks
service.
Cloud
Tasks
allows developers to manage the execution of background work in their applications.
Attributes
@private
Public Class Methods
Configure the CloudTasks
Client
class.
See {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client::Configuration} for a description of the configuration fields.
@example
# Modify the configuration for all CloudTasks clients ::Google::Cloud::Tasks::V2beta2::CloudTasks::Client.configure do |config| config.timeout = 10.0 end
@yield [config] Configure the Client
client. @yieldparam config [Client::Configuration]
@return [Client::Configuration]
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 57 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "Tasks", "V2beta2"] 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: [14, 4] } 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: [14, 4] } 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: [14, 4] } 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: [14, 4] } 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: [14, 4] } 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: [14, 4] } 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: [14, 4] } 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: [14, 4] } default_config.rpcs.lease_tasks.timeout = 20.0 default_config.rpcs.acknowledge_task.timeout = 20.0 default_config.rpcs.renew_lease.timeout = 20.0 default_config.rpcs.cancel_lease.timeout = 20.0 default_config.rpcs.run_task.timeout = 20.0 default_config end yield @configure if block_given? @configure end
Create a new CloudTasks
client object.
@example
# Create a client using the default configuration client = ::Google::Cloud::Tasks::V2beta2::CloudTasks::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Tasks::V2beta2::CloudTasks::Client.new do |config| config.timeout = 10.0 end
@yield [config] Configure the CloudTasks
client. @yieldparam config [Client::Configuration]
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 174 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/v2beta2/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 == Client.configure.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::V2beta2::CloudTasks::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end
Public Instance Methods
Acknowledges a pull task.
The worker, that is, the entity that {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks leased} this task must call this method to indicate that the work associated with the task has finished.
The worker must acknowledge a task within the {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration} or the lease will expire and the task will become available to be leased again. After the task is acknowledged, it will not be returned by a later {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks LeaseTasks}, {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#get_task GetTask}, or {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#list_tasks ListTasks}.
@overload acknowledge_task
(request, options = nil)
Pass arguments to `acknowledge_task` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest, ::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload acknowledge_task
(name: nil, schedule_time: nil)
Pass arguments to `acknowledge_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). @param name [::String] Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` @param schedule_time [::Google::Protobuf::Timestamp, ::Hash] Required. The task's current schedule time, available in the {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks LeaseTasks} response or {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#renew_lease RenewLease} response. This restriction is to ensure that your worker currently holds the lease.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Protobuf::Empty]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1728 def acknowledge_task request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest # 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 metadata = @config.rpcs.acknowledge_task.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.acknowledge_task.timeout, metadata: metadata, retry_policy: @config.rpcs.acknowledge_task.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_tasks_stub.call_rpc :acknowledge_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
Cancel a pull task's lease.
The worker can use this method to cancel a task's lease by setting its {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} to now. This will make the task available to be leased to the next caller of {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks LeaseTasks}.
@overload cancel_lease
(request, options = nil)
Pass arguments to `cancel_lease` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::CancelLeaseRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::CancelLeaseRequest, ::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload cancel_lease
(name: nil, schedule_time: nil, response_view: nil)
Pass arguments to `cancel_lease` 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). @param name [::String] Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` @param schedule_time [::Google::Protobuf::Timestamp, ::Hash] Required. The task's current schedule time, available in the {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks LeaseTasks} response or {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#renew_lease RenewLease} response. This restriction is to ensure that your worker currently holds the lease. @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View] The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be returned. By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC 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 {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Task] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Task]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1919 def cancel_lease request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::CancelLeaseRequest # 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 metadata = @config.rpcs.cancel_lease.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.cancel_lease.timeout, metadata: metadata, retry_policy: @config.rpcs.cancel_lease.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_tasks_stub.call_rpc :cancel_lease, 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
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 {Client.configure}.
See {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client::Configuration} for a description of the configuration fields.
@yield [config] Configure the Client
client. @yieldparam config [Client::Configuration]
@return [Client::Configuration]
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 153 def configure yield @config if block_given? @config end
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](cloud.google.com/tasks/docs/queue-yaml) before using this method.
@overload create_queue
(request, options = nil)
Pass arguments to `create_queue` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::CreateQueueRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload create_queue
(parent: nil, queue: nil)
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). @param parent [::String] 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 [ListLocations][google.cloud.location.Locations.ListLocations]. @param queue [::Google::Cloud::Tasks::V2beta2::Queue, ::Hash] Required. The queue to create. [Queue's name][google.cloud.tasks.v2beta2.Queue.name] cannot be the same as an existing queue.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Queue] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Queue]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 441 def create_queue request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.create_queue.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.create_queue.timeout, metadata: metadata, retry_policy: @config.rpcs.create_queue.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Creates a task and adds it to a queue.
Tasks
cannot be updated after creation; there is no UpdateTask command.
-
For {::Google::Cloud::Tasks::V2beta2::AppEngineHttpTarget App Engine queues}, the maximum task size is 100KB.
-
For {::Google::Cloud::Tasks::V2beta2::PullTarget pull queues}, the maximum task size is 1MB.
@overload create_task
(request, options = nil)
Pass arguments to `create_task` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::CreateTaskRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload create_task
(parent: nil, task: nil, response_view: nil)
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). @param parent [::String] Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist. @param task [::Google::Cloud::Tasks::V2beta2::Task, ::Hash] 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 {::Google::Cloud::Tasks::V2beta2::Task#name 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 {::Google::Cloud::Tasks::V2beta2::Task#name response}. If {::Google::Cloud::Tasks::V2beta2::Task#schedule_time 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 completed 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 completed. 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 completed. Because there is an extra lookup cost to identify duplicate task names, these {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#create_task 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. @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View] The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be returned. By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC 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 {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Task] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Task]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1404 def create_task request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.create_task.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.create_task.timeout, metadata: metadata, retry_policy: @config.rpcs.create_task.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
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](cloud.google.com/tasks/docs/queue-yaml) before using this method.
@overload delete_queue
(request, options = nil)
Pass arguments to `delete_queue` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::DeleteQueueRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload delete_queue
(name: nil)
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). @param name [::String] Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Protobuf::Empty]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 614 def delete_queue request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.delete_queue.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.delete_queue.timeout, metadata: metadata, retry_policy: @config.rpcs.delete_queue.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Deletes a task.
A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has completed successfully or permanently failed.
@overload delete_task
(request, options = nil)
Pass arguments to `delete_task` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::DeleteTaskRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload delete_task
(name: nil)
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). @param name [::String] Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Protobuf::Empty]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1477 def delete_task request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.delete_task.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.delete_task.timeout, metadata: metadata, retry_policy: @config.rpcs.delete_task.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Gets the access control policy for a {::Google::Cloud::Tasks::V2beta2::Queue Queue}. Returns an empty policy if the resource exists and does not have a policy set.
Authorization requires the following [Google IAM](cloud.google.com/iam) permission on the specified resource parent:
-
`cloudtasks.queues.getIamPolicy`
@overload get_iam_policy
(request, options = nil)
Pass arguments to `get_iam_policy` via a request object, either of type {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload get_iam_policy
(resource: nil, options: nil)
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). @param resource [::String] REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash] OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`. This field is only used by Cloud IAM.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Iam::V1::Policy] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Iam::V1::Policy]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 924 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 metadata = @config.rpcs.get_iam_policy.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "resource" => request.resource } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout, metadata: metadata, retry_policy: @config.rpcs.get_iam_policy.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Gets a queue.
@overload get_queue
(request, options = nil)
Pass arguments to `get_queue` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::GetQueueRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload get_queue
(name: nil, read_mask: nil)
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). @param name [::String] Required. The resource name of the queue. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` @param read_mask [::Google::Protobuf::FieldMask, ::Hash] Optional. Read mask is used for a more granular control over what the API returns. If the mask is not present all fields will be returned except [Queue.stats]. [Queue.stats] will be returned only if it was explicitly specified in the mask.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Queue] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Queue]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 353 def get_queue request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.get_queue.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.get_queue.timeout, metadata: metadata, retry_policy: @config.rpcs.get_queue.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Gets a task.
@overload get_task
(request, options = nil)
Pass arguments to `get_task` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::GetTaskRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload get_task
(name: nil, response_view: nil)
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). @param name [::String] Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View] The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be returned. By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC 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 {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Task] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Task]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1280 def get_task request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.get_task.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.get_task.timeout, metadata: metadata, retry_policy: @config.rpcs.get_task.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Leases tasks from a pull queue for {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration}.
This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#acknowledge_task AcknowledgeTask} after they have performed the work associated with the task.
The {::Google::Cloud::Tasks::V2beta2::PullMessage#payload payload} is intended to store data that the worker needs to perform the work associated with the task. To return the payloads in the {::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response}, set {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#response_view response_view} to {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL}.
A maximum of 10 qps of {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks LeaseTasks} requests are allowed per queue. [RESOURCE_EXHAUSTED] is returned when this limit is exceeded. [RESOURCE_EXHAUSTED] is also returned when {::Google::Cloud::Tasks::V2beta2::RateLimits#max_tasks_dispatched_per_second max_tasks_dispatched_per_second} is exceeded.
@overload lease_tasks
(request, options = nil)
Pass arguments to `lease_tasks` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest, ::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload lease_tasks
(parent: nil, max_tasks: nil, lease_duration: nil, response_view: nil, filter: nil)
Pass arguments to `lease_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). @param parent [::String] Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` @param max_tasks [::Integer] The maximum number of tasks to lease. The system will make a best effort to return as close to as `max_tasks` as possible. The largest that `max_tasks` can be is 1000. The maximum total size of a {::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse lease tasks response} is 32 MB. If the sum of all task sizes requested reaches this limit, fewer tasks than requested are returned. @param lease_duration [::Google::Protobuf::Duration, ::Hash] Required. The duration of the lease. Each task returned in the {::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response} will have its {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} set to the current time plus the `lease_duration`. The task is leased until its {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}; thus, the task will not be returned to another {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks LeaseTasks} call before its {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}. After the worker has successfully finished the work associated with the task, the worker must call via {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#acknowledge_task AcknowledgeTask} before the {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}. Otherwise the task will be returned to a later {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks LeaseTasks} call so that another worker can retry it. The maximum lease duration is 1 week. `lease_duration` will be truncated to the nearest second. @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View] The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be returned. By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC 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 {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource. @param filter [::String] `filter` can be used to specify a subset of tasks to lease. When `filter` is set to `tag=<my-tag>` then the {::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response} will contain only tasks whose {::Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} is equal to `<my-tag>`. `<my-tag>` must be less than 500 characters. When `filter` is set to `tag_function=oldest_tag()`, only tasks which have the same tag as the task with the oldest {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be returned. Grammar Syntax: * `filter = "tag=" tag | "tag_function=" function` * `tag = string` * `function = "oldest_tag()"` The `oldest_tag()` function returns tasks which have the same tag as the oldest task (ordered by schedule time). SDK compatibility: Although the SDK allows tags to be either string or [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-), only UTF-8 encoded tags can be used in Cloud Tasks. Tag which aren't UTF-8 encoded can't be used in the {::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#filter filter} and the task's {::Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} will be displayed as empty in Cloud Tasks.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::LeaseTasksResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1641 def lease_tasks request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::LeaseTasksRequest # 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 metadata = @config.rpcs.lease_tasks.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.lease_tasks.timeout, metadata: metadata, retry_policy: @config.rpcs.lease_tasks.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_tasks_stub.call_rpc :lease_tasks, 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
Lists queues.
Queues are returned in lexicographical order.
@overload list_queues
(request, options = nil)
Pass arguments to `list_queues` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::ListQueuesRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload list_queues
(parent: nil, filter: nil, page_size: nil, page_token: nil, read_mask: nil)
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). @param parent [::String] Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID` @param filter [::String] `filter` can be used to specify a subset of queues. Any {::Google::Cloud::Tasks::V2beta2::Queue 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](https://cloud.google.com/logging/docs/view/advanced_filters). Sample filter "app_engine_http_target: *". Note that using filters might cause fewer queues than the requested_page size to be returned. @param page_size [::Integer] 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 {::Google::Cloud::Tasks::V2beta2::ListQueuesResponse#next_page_token next_page_token} in the response to determine if more queues exist. @param page_token [::String] 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 {::Google::Cloud::Tasks::V2beta2::ListQueuesResponse#next_page_token next_page_token} returned from the previous call to {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#list_queues ListQueues} method. It is an error to switch the value of the {::Google::Cloud::Tasks::V2beta2::ListQueuesRequest#filter filter} while iterating through pages. @param read_mask [::Google::Protobuf::FieldMask, ::Hash] Optional. Read mask is used for a more granular control over what the API returns. If the mask is not present all fields will be returned except [Queue.stats]. [Queue.stats] will be returned only if it was explicitly specified in the mask.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2beta2::Queue>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2beta2::Queue>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 278 def list_queues request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.list_queues.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.list_queues.timeout, metadata: metadata, retry_policy: @config.rpcs.list_queues.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Lists the tasks in a queue.
By default, only the {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC} view is retrieved due to performance considerations; {::Google::Cloud::Tasks::V2beta2::ListTasksRequest#response_view 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.
@overload list_tasks
(request, options = nil)
Pass arguments to `list_tasks` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::ListTasksRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload list_tasks
(parent: nil, response_view: nil, page_size: nil, page_token: nil)
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). @param parent [::String] Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View] The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be returned. By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC 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 {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource. @param page_size [::Integer] Maximum page size. Fewer tasks than requested might be returned, even if more tasks exist; use {::Google::Cloud::Tasks::V2beta2::ListTasksResponse#next_page_token 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. @param page_token [::String] 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 {::Google::Cloud::Tasks::V2beta2::ListTasksResponse#next_page_token next_page_token} returned from the previous call to {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#list_tasks ListTasks} method. The page token is valid for only 2 hours.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2beta2::Task>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Gapic::PagedEnumerable<::Google::Cloud::Tasks::V2beta2::Task>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1197 def list_tasks request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.list_tasks.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.list_tasks.timeout, metadata: metadata, retry_policy: @config.rpcs.list_tasks.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Pauses the queue.
If a queue is paused then the system will stop dispatching tasks until the queue is resumed via {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#resume_queue ResumeQueue}. Tasks
can still be added when the queue is paused. A queue is paused if its {::Google::Cloud::Tasks::V2beta2::Queue#state state} is {::Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
@overload pause_queue
(request, options = nil)
Pass arguments to `pause_queue` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::PauseQueueRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload pause_queue
(name: nil)
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). @param name [::String] Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Queue] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Queue]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 763 def pause_queue request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.pause_queue.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.pause_queue.timeout, metadata: metadata, retry_policy: @config.rpcs.pause_queue.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
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.
@overload purge_queue
(request, options = nil)
Pass arguments to `purge_queue` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::PurgeQueueRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload purge_queue
(name: nil)
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). @param name [::String] Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Queue] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Queue]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 688 def purge_queue request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.purge_queue.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.purge_queue.timeout, metadata: metadata, retry_policy: @config.rpcs.purge_queue.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Renew the current lease of a pull task.
The worker can use this method to extend the lease by a new duration, starting from now. The new task lease will be returned in the task's {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}.
@overload renew_lease
(request, options = nil)
Pass arguments to `renew_lease` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::RenewLeaseRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::RenewLeaseRequest, ::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload renew_lease
(name: nil, schedule_time: nil, lease_duration: nil, response_view: nil)
Pass arguments to `renew_lease` 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). @param name [::String] Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` @param schedule_time [::Google::Protobuf::Timestamp, ::Hash] Required. The task's current schedule time, available in the {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#lease_tasks LeaseTasks} response or {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#renew_lease RenewLease} response. This restriction is to ensure that your worker currently holds the lease. @param lease_duration [::Google::Protobuf::Duration, ::Hash] Required. The desired new lease duration, starting from now. The maximum lease duration is 1 week. `lease_duration` will be truncated to the nearest second. @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View] The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be returned. By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC 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 {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Task] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Task]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1826 def renew_lease request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::RenewLeaseRequest # 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 metadata = @config.rpcs.renew_lease.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.renew_lease.timeout, metadata: metadata, retry_policy: @config.rpcs.renew_lease.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_tasks_stub.call_rpc :renew_lease, 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 a queue.
This method resumes a queue after it has been {::Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED} or {::Google::Cloud::Tasks::V2beta2::Queue::State::DISABLED DISABLED}. The state of a queue is stored in the queue's {::Google::Cloud::Tasks::V2beta2::Queue#state state}; after calling this method it will be set to {::Google::Cloud::Tasks::V2beta2::Queue::State::RUNNING 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](cloud.google.com/tasks/docs/manage-cloud-task-scaling).
@overload resume_queue
(request, options = nil)
Pass arguments to `resume_queue` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::ResumeQueueRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload resume_queue
(name: nil)
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). @param name [::String] Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Queue] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Queue]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 844 def resume_queue request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.resume_queue.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.resume_queue.timeout, metadata: metadata, retry_policy: @config.rpcs.resume_queue.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
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 {::Google::Cloud::Tasks::V2beta2::RateLimits RateLimits} or is {::Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
This command is meant to be used for manual debugging. For example, {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#run_task 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 {::Google::Cloud::Tasks::V2beta2::Task#status 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 {::Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be reset to the time that {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#run_task RunTask} was called plus the retry delay specified in the queue's {::Google::Cloud::Tasks::V2beta2::RetryConfig RetryConfig}.
{::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#run_task RunTask} returns
- NOT_FOUND][google.rpc.Code.NOT_FOUND
-
when it is called on a
task that has already succeeded or permanently failed.
{::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#run_task RunTask} cannot be called on a {::Google::Cloud::Tasks::V2beta2::PullMessage pull task}.
@overload run_task
(request, options = nil)
Pass arguments to `run_task` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::RunTaskRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload run_task
(name: nil, response_view: nil)
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). @param name [::String] Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` @param response_view [::Google::Cloud::Tasks::V2beta2::Task::View] The response_view specifies which subset of the {::Google::Cloud::Tasks::V2beta2::Task Task} will be returned. By default response_view is {::Google::Cloud::Tasks::V2beta2::Task::View::BASIC 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 {::Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the {::Google::Cloud::Tasks::V2beta2::Task Task} resource.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Task] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Task]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 2027 def run_task request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.run_task.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.run_task.timeout, metadata: metadata, retry_policy: @config.rpcs.run_task.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Sets the access control policy for a {::Google::Cloud::Tasks::V2beta2::Queue 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](cloud.google.com/iam) permission on the specified resource parent:
-
`cloudtasks.queues.setIamPolicy`
@overload set_iam_policy
(request, options = nil)
Pass arguments to `set_iam_policy` via a request object, either of type {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload set_iam_policy
(resource: nil, policy: nil)
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). @param resource [::String] REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. @param policy [::Google::Iam::V1::Policy, ::Hash] 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.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Iam::V1::Policy] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Iam::V1::Policy]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1008 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 metadata = @config.rpcs.set_iam_policy.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "resource" => request.resource } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout, metadata: metadata, retry_policy: @config.rpcs.set_iam_policy.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
Returns permissions that a caller has on a {::Google::Cloud::Tasks::V2beta2::Queue Queue}. If the resource does not exist, this will return an empty set of permissions, not a [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.
@overload test_iam_permissions
(request, options = nil)
Pass arguments to `test_iam_permissions` via a request object, either of type {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload test_iam_permissions
(resource: nil, permissions: nil)
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). @param resource [::String] REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. @param permissions [::Array<::String>] 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](https://cloud.google.com/iam/docs/overview#permissions).
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Iam::V1::TestIamPermissionsResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Iam::V1::TestIamPermissionsResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 1088 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 metadata = @config.rpcs.test_iam_permissions.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "resource" => request.resource } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout, metadata: metadata, retry_policy: @config.rpcs.test_iam_permissions.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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
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](cloud.google.com/tasks/docs/queue-yaml) before using this method.
@overload update_queue
(request, options = nil)
Pass arguments to `update_queue` via a request object, either of type {::Google::Cloud::Tasks::V2beta2::UpdateQueueRequest} or an equivalent Hash. @param request [::Google::Cloud::Tasks::V2beta2::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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload update_queue
(queue: nil, update_mask: nil)
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). @param queue [::Google::Cloud::Tasks::V2beta2::Queue, ::Hash] Required. The queue to create or update. The queue's {::Google::Cloud::Tasks::V2beta2::Queue#name 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 {::Google::Cloud::Tasks::V2beta2::Queue#name name} cannot be changed. @param update_mask [::Google::Protobuf::FieldMask, ::Hash] A mask used to specify which fields of the queue are being updated. If empty, then all fields will be updated.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Tasks::V2beta2::Queue] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Tasks::V2beta2::Queue]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/tasks/v2beta2/cloud_tasks/client.rb, line 533 def update_queue request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::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 metadata = @config.rpcs.update_queue.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"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::V2beta2::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "queue.name" => request.queue.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.update_queue.timeout, metadata: metadata, retry_policy: @config.rpcs.update_queue.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, 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