CloudTasks¶
- class google.cloud.tasks_v2beta2.services.cloud_tasks.CloudTasksAsyncClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.tasks_v2beta2.services.cloud_tasks.transports.base.CloudTasksTransport, typing.Callable[[...], google.cloud.tasks_v2beta2.services.cloud_tasks.transports.base.CloudTasksTransport]]] = 'grpc_asyncio', client_options: typing.Optional[google.api_core.client_options.ClientOptions] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)[source]¶
Cloud Tasks allows developers to manage the execution of background work in their applications.
Instantiates the cloud tasks async client.
- Parameters
credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.
transport (Optional[Union[str,CloudTasksTransport,Callable[..., CloudTasksTransport]]]) – The transport to use, or a Callable that constructs and returns a new transport to use. If a Callable is given, it will be called with the same set of initialization arguments as used in the CloudTasksTransport constructor. If set to None, a transport is chosen automatically.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]) –
Custom options for the client.
1. The
api_endpoint
property can be used to override the default endpoint provided by the client whentransport
is not explicitly provided. Only if this property is not set andtransport
was not explicitly provided, the endpoint is determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment variable, which have one of the following values: “always” (always use the default mTLS endpoint), “never” (always use the default regular endpoint) and “auto” (auto-switch to the default mTLS endpoint if client certificate is present; this is the default value).2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “true”, then the
client_cert_source
property can be used to provide a client certificate for mTLS transport. If not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is “false” or not set, no client certificate will be used.3. The
universe_domain
property can be used to override the default “googleapis.com” universe. Note thatapi_endpoint
property still takes precedence; anduniverse_domain
is currently not supported for mTLS.client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If
None
, then default info will be used. Generally, you only need to set this if you’re developing your own client library.
- Raises
google.auth.exceptions.MutualTlsChannelError – If mutual TLS transport creation failed for any reason.
- async acknowledge_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.AcknowledgeTaskRequest, dict]] = None, *, name: Optional[str] = None, schedule_time: Optional[google.protobuf.timestamp_pb2.Timestamp] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Acknowledges a pull task.
The worker, that is, the entity that [leased][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] 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 [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.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 [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks], [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask], or [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_acknowledge_task(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.AcknowledgeTaskRequest( name="name_value", ) # Make the request await client.acknowledge_task(request=request)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest, dict]]) – The request object. Request message for acknowledging a task using [AcknowledgeTask][google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask].
name (
str
) –Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.schedule_time (
google.protobuf.timestamp_pb2.Timestamp
) –Required. The task’s current schedule time, available in the [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction is to ensure that your worker currently holds the lease.
This corresponds to the
schedule_time
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- property api_endpoint¶
Return the API endpoint used by the client instance.
- Returns
The API endpoint used by the client instance.
- Return type
- async cancel_lease(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.CancelLeaseRequest, dict]] = None, *, name: Optional[str] = None, schedule_time: Optional[google.protobuf.timestamp_pb2.Timestamp] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
Cancel a pull task’s lease.
The worker can use this method to cancel a task’s lease by setting its [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] to now. This will make the task available to be leased to the next caller of [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_cancel_lease(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.CancelLeaseRequest( name="name_value", ) # Make the request response = await client.cancel_lease(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.CancelLeaseRequest, dict]]) – The request object. Request message for canceling a lease using [CancelLease][google.cloud.tasks.v2beta2.CloudTasks.CancelLease].
name (
str
) –Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.schedule_time (
google.protobuf.timestamp_pb2.Timestamp
) –Required. The task’s current schedule time, available in the [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction is to ensure that your worker currently holds the lease.
This corresponds to the
schedule_time
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- static common_billing_account_path(billing_account: str) str ¶
Returns a fully-qualified billing_account string.
- static common_location_path(project: str, location: str) str ¶
Returns a fully-qualified location string.
- static common_organization_path(organization: str) str ¶
Returns a fully-qualified organization string.
- async create_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.CreateQueueRequest, dict]] = None, *, parent: Optional[str] = None, queue: Optional[google.cloud.tasks_v2beta2.types.queue.Queue] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
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
orqueue.xml
file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_create_queue(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.CreateQueueRequest( parent="parent_value", ) # Make the request response = await client.create_queue(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.CreateQueueRequest, dict]]) – The request object. Request message for [CreateQueue][google.cloud.tasks.v2beta2.CloudTasks.CreateQueue].
parent (
str
) –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].
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.queue (
google.cloud.tasks_v2beta2.types.Queue
) –Required. The queue to create.
[Queue’s name][google.cloud.tasks.v2beta2.Queue.name] cannot be the same as an existing queue.
This corresponds to the
queue
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- async create_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.CreateTaskRequest, dict]] = None, *, parent: Optional[str] = None, task: Optional[google.cloud.tasks_v2beta2.types.task.Task] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
Creates a task and adds it to a queue.
Tasks cannot be updated after creation; there is no UpdateTask command.
For [App Engine queues][google.cloud.tasks.v2beta2.AppEngineHttpTarget], the maximum task size is 100KB.
For [pull queues][google.cloud.tasks.v2beta2.PullTarget], the maximum task size is 1MB.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_create_task(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.CreateTaskRequest( parent="parent_value", ) # Make the request response = await client.create_task(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.CreateTaskRequest, dict]]) – The request object. Request message for [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.CreateTask].
parent (
str
) –Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
The queue must already exist.
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.task (
google.cloud.tasks_v2beta2.types.Task
) –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][google.cloud.tasks.v2beta2.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][google.cloud.tasks.v2beta2.Task.name].If [schedule_time][google.cloud.tasks.v2beta2.Task.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 ~1 hour 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 ~9 days after the original task was deleted or completed.
Because there is an extra lookup cost to identify duplicate task names, these [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.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.
This corresponds to the
task
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- async delete_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.DeleteQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
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
orqueue.xml
file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_delete_queue(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.DeleteQueueRequest( name="name_value", ) # Make the request await client.delete_queue(request=request)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.DeleteQueueRequest, dict]]) – The request object. Request message for [DeleteQueue][google.cloud.tasks.v2beta2.CloudTasks.DeleteQueue].
name (
str
) –Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- async delete_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.DeleteTaskRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_delete_task(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.DeleteTaskRequest( name="name_value", ) # Make the request await client.delete_task(request=request)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.DeleteTaskRequest, dict]]) – The request object. Request message for deleting a task using [DeleteTask][google.cloud.tasks.v2beta2.CloudTasks.DeleteTask].
name (
str
) –Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- classmethod from_service_account_file(filename: str, *args, **kwargs)[source]¶
- Creates an instance of this client using the provided credentials
file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- classmethod from_service_account_info(info: dict, *args, **kwargs)[source]¶
- Creates an instance of this client using the provided credentials
info.
- Parameters
info (dict) – The service account private key info.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- classmethod from_service_account_json(filename: str, *args, **kwargs)¶
- Creates an instance of this client using the provided credentials
file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- async get_iam_policy(request: Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]] = None, *, resource: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.policy_pb2.Policy [source]¶
Gets the access control policy for a [Queue][google.cloud.tasks.v2beta2.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
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request response = await client.get_iam_policy(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]) – The request object. Request message for
GetIamPolicy
method.resource (
str
) –REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- An Identity and Access Management (IAM) policy, which specifies access
controls for Google Cloud resources.
A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role.
For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
JSON example:
` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }
`YAML example:
` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3
`For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
- Return type
google.iam.v1.policy_pb2.Policy
- async get_location(request: Optional[google.cloud.location.locations_pb2.GetLocationRequest] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.location.locations_pb2.Location [source]¶
Gets information about a location.
- Parameters
request (
GetLocationRequest
) – The request object. Request message for GetLocation method.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Location object.
- Return type
Location
- classmethod get_mtls_endpoint_and_cert_source(client_options: Optional[google.api_core.client_options.ClientOptions] = None)[source]¶
Return the API endpoint and client cert source for mutual TLS.
The client cert source is determined in the following order: (1) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is not “true”, the client cert source is None. (2) if client_options.client_cert_source is provided, use the provided one; if the default client cert source exists, use the default one; otherwise the client cert source is None.
The API endpoint is determined in the following order: (1) if client_options.api_endpoint if provided, use the provided one. (2) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “always”, use the default mTLS endpoint; if the environment variable is “never”, use the default API endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise use the default API endpoint.
More details can be found at https://google.aip.dev/auth/4114.
- Parameters
client_options (google.api_core.client_options.ClientOptions) – Custom options for the client. Only the api_endpoint and client_cert_source properties may be used in this method.
- Returns
- returns the API endpoint and the
client cert source to use.
- Return type
- Raises
google.auth.exceptions.MutualTLSChannelError – If any errors happen.
- async get_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.GetQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
Gets a queue.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_get_queue(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.GetQueueRequest( name="name_value", ) # Make the request response = await client.get_queue(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.GetQueueRequest, dict]]) – The request object. Request message for [GetQueue][google.cloud.tasks.v2beta2.CloudTasks.GetQueue].
name (
str
) –Required. The resource name of the queue. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- async get_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.GetTaskRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
Gets a task.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_get_task(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.GetTaskRequest( name="name_value", ) # Make the request response = await client.get_task(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.GetTaskRequest, dict]]) – The request object. Request message for getting a task using [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask].
name (
str
) –Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- classmethod get_transport_class(label: Optional[str] = None) Type[google.cloud.tasks_v2beta2.services.cloud_tasks.transports.base.CloudTasksTransport] ¶
Returns an appropriate transport class.
- Parameters
label – The name of the desired transport. If none is provided, then the first transport in the registry is used.
- Returns
The transport class to use.
- async lease_tasks(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.LeaseTasksRequest, dict]] = None, *, parent: Optional[str] = None, lease_duration: Optional[google.protobuf.duration_pb2.Duration] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.cloudtasks.LeaseTasksResponse [source]¶
Leases tasks from a pull queue for [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration].
This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via [AcknowledgeTask][google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask] after they have performed the work associated with the task.
The [payload][google.cloud.tasks.v2beta2.PullMessage.payload] is intended to store data that the worker needs to perform the work associated with the task. To return the payloads in the [response][google.cloud.tasks.v2beta2.LeaseTasksResponse], set [response_view][google.cloud.tasks.v2beta2.LeaseTasksRequest.response_view] to [FULL][google.cloud.tasks.v2beta2.Task.View.FULL].
A maximum of 10 qps of [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] requests are allowed per queue. [RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED] is returned when this limit is exceeded. [RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED] is also returned when [max_tasks_dispatched_per_second][google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second] is exceeded.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_lease_tasks(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.LeaseTasksRequest( parent="parent_value", ) # Make the request response = await client.lease_tasks(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.LeaseTasksRequest, dict]]) – The request object. Request message for leasing tasks using [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].
parent (
str
) –Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.lease_duration (
google.protobuf.duration_pb2.Duration
) –Required. The duration of the lease.
Each task returned in the [response][google.cloud.tasks.v2beta2.LeaseTasksResponse] will have its [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] set to the current time plus the
lease_duration
. The task is leased until its [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]; thus, the task will not be returned to another [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] call before its [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time].After the worker has successfully finished the work associated with the task, the worker must call via [AcknowledgeTask][google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask] before the [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. Otherwise the task will be returned to a later [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.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.This corresponds to the
lease_duration
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Response message for leasing tasks using
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].
- Return type
- async list_locations(request: Optional[google.cloud.location.locations_pb2.ListLocationsRequest] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.location.locations_pb2.ListLocationsResponse [source]¶
Lists information about the supported locations for this service.
- Parameters
request (
ListLocationsRequest
) – The request object. Request message for ListLocations method.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Response message for
ListLocations
method.- Return type
ListLocationsResponse
- async list_queues(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.ListQueuesRequest, dict]] = None, *, parent: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesAsyncPager [source]¶
Lists queues.
Queues are returned in lexicographical order.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_list_queues(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.ListQueuesRequest( parent="parent_value", ) # Make the request page_result = client.list_queues(request=request) # Handle the response async for response in page_result: print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.ListQueuesRequest, dict]]) – The request object. Request message for [ListQueues][google.cloud.tasks.v2beta2.CloudTasks.ListQueues].
parent (
str
) –Required. The location name. For example:
projects/PROJECT_ID/locations/LOCATION_ID
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Response message for
[ListQueues][google.cloud.tasks.v2beta2.CloudTasks.ListQueues].
Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesAsyncPager
- async list_tasks(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.ListTasksRequest, dict]] = None, *, parent: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksAsyncPager [source]¶
Lists the tasks in a queue.
By default, only the [BASIC][google.cloud.tasks.v2beta2.Task.View.BASIC] view is retrieved due to performance considerations; [response_view][google.cloud.tasks.v2beta2.ListTasksRequest.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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_list_tasks(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.ListTasksRequest( parent="parent_value", ) # Make the request page_result = client.list_tasks(request=request) # Handle the response async for response in page_result: print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.ListTasksRequest, dict]]) – The request object. Request message for listing tasks using [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks].
parent (
str
) –Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Response message for listing tasks using
[ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks].
Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksAsyncPager
- static parse_common_billing_account_path(path: str) Dict[str, str] ¶
Parse a billing_account path into its component segments.
- static parse_common_folder_path(path: str) Dict[str, str] ¶
Parse a folder path into its component segments.
- static parse_common_location_path(path: str) Dict[str, str] ¶
Parse a location path into its component segments.
- static parse_common_organization_path(path: str) Dict[str, str] ¶
Parse a organization path into its component segments.
- static parse_common_project_path(path: str) Dict[str, str] ¶
Parse a project path into its component segments.
- static parse_queue_path(path: str) Dict[str, str] ¶
Parses a queue path into its component segments.
- async pause_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.PauseQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
Pauses the queue.
If a queue is paused then the system will stop dispatching tasks until the queue is resumed via [ResumeQueue][google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue]. Tasks can still be added when the queue is paused. A queue is paused if its [state][google.cloud.tasks.v2beta2.Queue.state] is [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_pause_queue(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.PauseQueueRequest( name="name_value", ) # Make the request response = await client.pause_queue(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.PauseQueueRequest, dict]]) – The request object. Request message for [PauseQueue][google.cloud.tasks.v2beta2.CloudTasks.PauseQueue].
name (
str
) –Required. The queue name. For example:
projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- async purge_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.PurgeQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_purge_queue(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.PurgeQueueRequest( name="name_value", ) # Make the request response = await client.purge_queue(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.PurgeQueueRequest, dict]]) – The request object. Request message for [PurgeQueue][google.cloud.tasks.v2beta2.CloudTasks.PurgeQueue].
name (
str
) –Required. The queue name. For example:
projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- static queue_path(project: str, location: str, queue: str) str ¶
Returns a fully-qualified queue string.
- async renew_lease(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.RenewLeaseRequest, dict]] = None, *, name: Optional[str] = None, schedule_time: Optional[google.protobuf.timestamp_pb2.Timestamp] = None, lease_duration: Optional[google.protobuf.duration_pb2.Duration] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
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 [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_renew_lease(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.RenewLeaseRequest( name="name_value", ) # Make the request response = await client.renew_lease(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.RenewLeaseRequest, dict]]) – The request object. Request message for renewing a lease using [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease].
name (
str
) –Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.schedule_time (
google.protobuf.timestamp_pb2.Timestamp
) –Required. The task’s current schedule time, available in the [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction is to ensure that your worker currently holds the lease.
This corresponds to the
schedule_time
field on therequest
instance; ifrequest
is provided, this should not be set.lease_duration (
google.protobuf.duration_pb2.Duration
) –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.This corresponds to the
lease_duration
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- async resume_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.ResumeQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
Resume a queue.
This method resumes a queue after it has been [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED] or [DISABLED][google.cloud.tasks.v2beta2.Queue.State.DISABLED]. The state of a queue is stored in the queue’s [state][google.cloud.tasks.v2beta2.Queue.state]; after calling this method it will be set to [RUNNING][google.cloud.tasks.v2beta2.Queue.State.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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_resume_queue(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.ResumeQueueRequest( name="name_value", ) # Make the request response = await client.resume_queue(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.ResumeQueueRequest, dict]]) – The request object. Request message for [ResumeQueue][google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue].
name (
str
) –Required. The queue name. For example:
projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- async run_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.RunTaskRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
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][google.cloud.tasks.v2beta2.RateLimits] or is [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED].
This command is meant to be used for manual debugging. For example, [RunTask][google.cloud.tasks.v2beta2.CloudTasks.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][google.cloud.tasks.v2beta2.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][google.cloud.tasks.v2beta2.Task.schedule_time] will be reset to the time that [RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] was called plus the retry delay specified in the queue’s [RetryConfig][google.cloud.tasks.v2beta2.RetryConfig].
[RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] returns [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded or permanently failed.
[RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] cannot be called on a [pull task][google.cloud.tasks.v2beta2.PullMessage].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_run_task(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.RunTaskRequest( name="name_value", ) # Make the request response = await client.run_task(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.RunTaskRequest, dict]]) – The request object. Request message for forcing a task to run now using [RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask].
name (
str
) –Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- async set_iam_policy(request: Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]] = None, *, resource: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.policy_pb2.Policy [source]¶
Sets the access control policy for a [Queue][google.cloud.tasks.v2beta2.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
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request response = await client.set_iam_policy(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]) – The request object. Request message for
SetIamPolicy
method.resource (
str
) –REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- An Identity and Access Management (IAM) policy, which specifies access
controls for Google Cloud resources.
A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role.
For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
JSON example:
` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }
`YAML example:
` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3
`For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
- Return type
google.iam.v1.policy_pb2.Policy
- static task_path(project: str, location: str, queue: str, task: str) str ¶
Returns a fully-qualified task string.
- async test_iam_permissions(request: Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, *, resource: Optional[str] = None, permissions: Optional[MutableSequence[str]] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse [source]¶
Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta2.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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value1', 'permissions_value2'], ) # Make the request response = await client.test_iam_permissions(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]) – The request object. Request message for
TestIamPermissions
method.resource (
str
) –REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.permissions (
MutableSequence[str]
) –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.This corresponds to the
permissions
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Response message for TestIamPermissions method.
- Return type
google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse
- property transport: google.cloud.tasks_v2beta2.services.cloud_tasks.transports.base.CloudTasksTransport¶
Returns the transport used by the client instance.
- Returns
The transport used by the client instance.
- Return type
CloudTasksTransport
- property universe_domain: str¶
Return the universe domain used by the client instance.
- Returns
- The universe domain used
by the client instance.
- Return type
- async update_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.UpdateQueueRequest, dict]] = None, *, queue: Optional[google.cloud.tasks_v2beta2.types.queue.Queue] = None, update_mask: Optional[google.protobuf.field_mask_pb2.FieldMask] = None, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
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
orqueue.xml
file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_update_queue(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.UpdateQueueRequest( ) # Make the request response = await client.update_queue(request=request) # Handle the response print(response)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.UpdateQueueRequest, dict]]) – The request object. Request message for [UpdateQueue][google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue].
queue (
google.cloud.tasks_v2beta2.types.Queue
) –Required. The queue to create or update.
The queue’s [name][google.cloud.tasks.v2beta2.Queue.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][google.cloud.tasks.v2beta2.Queue.name] cannot be changed.
This corresponds to the
queue
field on therequest
instance; ifrequest
is provided, this should not be set.update_mask (
google.protobuf.field_mask_pb2.FieldMask
) –A mask used to specify which fields of the queue are being updated. If empty, then all fields will be updated.
This corresponds to the
update_mask
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- async upload_queue_yaml(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.UploadQueueYamlRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Update queue list by uploading a queue.yaml file.
The queue.yaml file is supplied in the request body as a YAML encoded string. This method was added to support gcloud clients versions before 322.0.0. New clients should use CreateQueue instead of this method.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 async def sample_upload_queue_yaml(): # Create a client client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.UploadQueueYamlRequest( app_id="app_id_value", ) # Make the request await client.upload_queue_yaml(request=request)
- Parameters
request (Optional[Union[google.cloud.tasks_v2beta2.types.UploadQueueYamlRequest, dict]]) – The request object. Request message for [UploadQueueYaml][google.cloud.tasks.v2beta2.CloudTasks.UploadQueueYaml].
retry (google.api_core.retry_async.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.tasks_v2beta2.services.cloud_tasks.CloudTasksClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.tasks_v2beta2.services.cloud_tasks.transports.base.CloudTasksTransport, typing.Callable[[...], google.cloud.tasks_v2beta2.services.cloud_tasks.transports.base.CloudTasksTransport]]] = None, client_options: typing.Optional[typing.Union[google.api_core.client_options.ClientOptions, dict]] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)[source]¶
Cloud Tasks allows developers to manage the execution of background work in their applications.
Instantiates the cloud tasks client.
- Parameters
credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.
transport (Optional[Union[str,CloudTasksTransport,Callable[..., CloudTasksTransport]]]) – The transport to use, or a Callable that constructs and returns a new transport. If a Callable is given, it will be called with the same set of initialization arguments as used in the CloudTasksTransport constructor. If set to None, a transport is chosen automatically.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]) –
Custom options for the client.
1. The
api_endpoint
property can be used to override the default endpoint provided by the client whentransport
is not explicitly provided. Only if this property is not set andtransport
was not explicitly provided, the endpoint is determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment variable, which have one of the following values: “always” (always use the default mTLS endpoint), “never” (always use the default regular endpoint) and “auto” (auto-switch to the default mTLS endpoint if client certificate is present; this is the default value).2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “true”, then the
client_cert_source
property can be used to provide a client certificate for mTLS transport. If not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is “false” or not set, no client certificate will be used.3. The
universe_domain
property can be used to override the default “googleapis.com” universe. Note that theapi_endpoint
property still takes precedence; anduniverse_domain
is currently not supported for mTLS.client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If
None
, then default info will be used. Generally, you only need to set this if you’re developing your own client library.
- Raises
google.auth.exceptions.MutualTLSChannelError – If mutual TLS transport creation failed for any reason.
- __exit__(type, value, traceback)[source]¶
Releases underlying transport’s resources.
Warning
ONLY use as a context manager if the transport is NOT shared with other clients! Exiting the with block will CLOSE the transport and may cause errors in other clients!
- acknowledge_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.AcknowledgeTaskRequest, dict]] = None, *, name: Optional[str] = None, schedule_time: Optional[google.protobuf.timestamp_pb2.Timestamp] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Acknowledges a pull task.
The worker, that is, the entity that [leased][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] 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 [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.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 [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks], [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask], or [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_acknowledge_task(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.AcknowledgeTaskRequest( name="name_value", ) # Make the request client.acknowledge_task(request=request)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest, dict]) – The request object. Request message for acknowledging a task using [AcknowledgeTask][google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask].
name (str) –
Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.schedule_time (google.protobuf.timestamp_pb2.Timestamp) –
Required. The task’s current schedule time, available in the [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction is to ensure that your worker currently holds the lease.
This corresponds to the
schedule_time
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- property api_endpoint¶
Return the API endpoint used by the client instance.
- Returns
The API endpoint used by the client instance.
- Return type
- cancel_lease(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.CancelLeaseRequest, dict]] = None, *, name: Optional[str] = None, schedule_time: Optional[google.protobuf.timestamp_pb2.Timestamp] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
Cancel a pull task’s lease.
The worker can use this method to cancel a task’s lease by setting its [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] to now. This will make the task available to be leased to the next caller of [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_cancel_lease(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.CancelLeaseRequest( name="name_value", ) # Make the request response = client.cancel_lease(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.CancelLeaseRequest, dict]) – The request object. Request message for canceling a lease using [CancelLease][google.cloud.tasks.v2beta2.CloudTasks.CancelLease].
name (str) –
Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.schedule_time (google.protobuf.timestamp_pb2.Timestamp) –
Required. The task’s current schedule time, available in the [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction is to ensure that your worker currently holds the lease.
This corresponds to the
schedule_time
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- static common_billing_account_path(billing_account: str) str [source]¶
Returns a fully-qualified billing_account string.
- static common_location_path(project: str, location: str) str [source]¶
Returns a fully-qualified location string.
- static common_organization_path(organization: str) str [source]¶
Returns a fully-qualified organization string.
- create_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.CreateQueueRequest, dict]] = None, *, parent: Optional[str] = None, queue: Optional[google.cloud.tasks_v2beta2.types.queue.Queue] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
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
orqueue.xml
file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_create_queue(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.CreateQueueRequest( parent="parent_value", ) # Make the request response = client.create_queue(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.CreateQueueRequest, dict]) – The request object. Request message for [CreateQueue][google.cloud.tasks.v2beta2.CloudTasks.CreateQueue].
parent (str) –
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].
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.queue (google.cloud.tasks_v2beta2.types.Queue) –
Required. The queue to create.
[Queue’s name][google.cloud.tasks.v2beta2.Queue.name] cannot be the same as an existing queue.
This corresponds to the
queue
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- create_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.CreateTaskRequest, dict]] = None, *, parent: Optional[str] = None, task: Optional[google.cloud.tasks_v2beta2.types.task.Task] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
Creates a task and adds it to a queue.
Tasks cannot be updated after creation; there is no UpdateTask command.
For [App Engine queues][google.cloud.tasks.v2beta2.AppEngineHttpTarget], the maximum task size is 100KB.
For [pull queues][google.cloud.tasks.v2beta2.PullTarget], the maximum task size is 1MB.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_create_task(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.CreateTaskRequest( parent="parent_value", ) # Make the request response = client.create_task(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.CreateTaskRequest, dict]) – The request object. Request message for [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.CreateTask].
parent (str) –
Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
The queue must already exist.
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.task (google.cloud.tasks_v2beta2.types.Task) –
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][google.cloud.tasks.v2beta2.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][google.cloud.tasks.v2beta2.Task.name].If [schedule_time][google.cloud.tasks.v2beta2.Task.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 ~1 hour 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 ~9 days after the original task was deleted or completed.
Because there is an extra lookup cost to identify duplicate task names, these [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.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.
This corresponds to the
task
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- delete_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.DeleteQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
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
orqueue.xml
file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_delete_queue(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.DeleteQueueRequest( name="name_value", ) # Make the request client.delete_queue(request=request)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.DeleteQueueRequest, dict]) – The request object. Request message for [DeleteQueue][google.cloud.tasks.v2beta2.CloudTasks.DeleteQueue].
name (str) –
Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- delete_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.DeleteTaskRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_delete_task(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.DeleteTaskRequest( name="name_value", ) # Make the request client.delete_task(request=request)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.DeleteTaskRequest, dict]) – The request object. Request message for deleting a task using [DeleteTask][google.cloud.tasks.v2beta2.CloudTasks.DeleteTask].
name (str) –
Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- classmethod from_service_account_file(filename: str, *args, **kwargs)[source]¶
- Creates an instance of this client using the provided credentials
file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- classmethod from_service_account_info(info: dict, *args, **kwargs)[source]¶
- Creates an instance of this client using the provided credentials
info.
- Parameters
info (dict) – The service account private key info.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- classmethod from_service_account_json(filename: str, *args, **kwargs)¶
- Creates an instance of this client using the provided credentials
file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
- get_iam_policy(request: Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]] = None, *, resource: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.policy_pb2.Policy [source]¶
Gets the access control policy for a [Queue][google.cloud.tasks.v2beta2.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
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request response = client.get_iam_policy(request=request) # Handle the response print(response)
- Parameters
request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]) – The request object. Request message for
GetIamPolicy
method.resource (str) –
REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- An Identity and Access Management (IAM) policy, which specifies access
controls for Google Cloud resources.
A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role.
For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
JSON example:
` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }
`YAML example:
` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3
`For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
- Return type
google.iam.v1.policy_pb2.Policy
- get_location(request: Optional[google.cloud.location.locations_pb2.GetLocationRequest] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.location.locations_pb2.Location [source]¶
Gets information about a location.
- Parameters
request (
GetLocationRequest
) – The request object. Request message for GetLocation method.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Location object.
- Return type
Location
- classmethod get_mtls_endpoint_and_cert_source(client_options: Optional[google.api_core.client_options.ClientOptions] = None)[source]¶
Deprecated. Return the API endpoint and client cert source for mutual TLS.
The client cert source is determined in the following order: (1) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is not “true”, the client cert source is None. (2) if client_options.client_cert_source is provided, use the provided one; if the default client cert source exists, use the default one; otherwise the client cert source is None.
The API endpoint is determined in the following order: (1) if client_options.api_endpoint if provided, use the provided one. (2) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “always”, use the default mTLS endpoint; if the environment variable is “never”, use the default API endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise use the default API endpoint.
More details can be found at https://google.aip.dev/auth/4114.
- Parameters
client_options (google.api_core.client_options.ClientOptions) – Custom options for the client. Only the api_endpoint and client_cert_source properties may be used in this method.
- Returns
- returns the API endpoint and the
client cert source to use.
- Return type
- Raises
google.auth.exceptions.MutualTLSChannelError – If any errors happen.
- get_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.GetQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
Gets a queue.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_get_queue(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.GetQueueRequest( name="name_value", ) # Make the request response = client.get_queue(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.GetQueueRequest, dict]) – The request object. Request message for [GetQueue][google.cloud.tasks.v2beta2.CloudTasks.GetQueue].
name (str) –
Required. The resource name of the queue. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- get_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.GetTaskRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
Gets a task.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_get_task(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.GetTaskRequest( name="name_value", ) # Make the request response = client.get_task(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.GetTaskRequest, dict]) – The request object. Request message for getting a task using [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask].
name (str) –
Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- lease_tasks(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.LeaseTasksRequest, dict]] = None, *, parent: Optional[str] = None, lease_duration: Optional[google.protobuf.duration_pb2.Duration] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.cloudtasks.LeaseTasksResponse [source]¶
Leases tasks from a pull queue for [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration].
This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via [AcknowledgeTask][google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask] after they have performed the work associated with the task.
The [payload][google.cloud.tasks.v2beta2.PullMessage.payload] is intended to store data that the worker needs to perform the work associated with the task. To return the payloads in the [response][google.cloud.tasks.v2beta2.LeaseTasksResponse], set [response_view][google.cloud.tasks.v2beta2.LeaseTasksRequest.response_view] to [FULL][google.cloud.tasks.v2beta2.Task.View.FULL].
A maximum of 10 qps of [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] requests are allowed per queue. [RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED] is returned when this limit is exceeded. [RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED] is also returned when [max_tasks_dispatched_per_second][google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second] is exceeded.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_lease_tasks(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.LeaseTasksRequest( parent="parent_value", ) # Make the request response = client.lease_tasks(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.LeaseTasksRequest, dict]) – The request object. Request message for leasing tasks using [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].
parent (str) –
Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.lease_duration (google.protobuf.duration_pb2.Duration) –
Required. The duration of the lease.
Each task returned in the [response][google.cloud.tasks.v2beta2.LeaseTasksResponse] will have its [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] set to the current time plus the
lease_duration
. The task is leased until its [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]; thus, the task will not be returned to another [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] call before its [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time].After the worker has successfully finished the work associated with the task, the worker must call via [AcknowledgeTask][google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask] before the [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. Otherwise the task will be returned to a later [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.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.This corresponds to the
lease_duration
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Response message for leasing tasks using
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].
- Return type
- list_locations(request: Optional[google.cloud.location.locations_pb2.ListLocationsRequest] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.location.locations_pb2.ListLocationsResponse [source]¶
Lists information about the supported locations for this service.
- Parameters
request (
ListLocationsRequest
) – The request object. Request message for ListLocations method.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Response message for
ListLocations
method.- Return type
ListLocationsResponse
- list_queues(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.ListQueuesRequest, dict]] = None, *, parent: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesPager [source]¶
Lists queues.
Queues are returned in lexicographical order.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_list_queues(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.ListQueuesRequest( parent="parent_value", ) # Make the request page_result = client.list_queues(request=request) # Handle the response for response in page_result: print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.ListQueuesRequest, dict]) – The request object. Request message for [ListQueues][google.cloud.tasks.v2beta2.CloudTasks.ListQueues].
parent (str) –
Required. The location name. For example:
projects/PROJECT_ID/locations/LOCATION_ID
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Response message for
[ListQueues][google.cloud.tasks.v2beta2.CloudTasks.ListQueues].
Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesPager
- list_tasks(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.ListTasksRequest, dict]] = None, *, parent: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksPager [source]¶
Lists the tasks in a queue.
By default, only the [BASIC][google.cloud.tasks.v2beta2.Task.View.BASIC] view is retrieved due to performance considerations; [response_view][google.cloud.tasks.v2beta2.ListTasksRequest.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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_list_tasks(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.ListTasksRequest( parent="parent_value", ) # Make the request page_result = client.list_tasks(request=request) # Handle the response for response in page_result: print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.ListTasksRequest, dict]) – The request object. Request message for listing tasks using [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks].
parent (str) –
Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
parent
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- Response message for listing tasks using
[ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks].
Iterating over this object will yield results and resolve additional pages automatically.
- Return type
google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksPager
- static parse_common_billing_account_path(path: str) Dict[str, str] [source]¶
Parse a billing_account path into its component segments.
- static parse_common_folder_path(path: str) Dict[str, str] [source]¶
Parse a folder path into its component segments.
- static parse_common_location_path(path: str) Dict[str, str] [source]¶
Parse a location path into its component segments.
- static parse_common_organization_path(path: str) Dict[str, str] [source]¶
Parse a organization path into its component segments.
- static parse_common_project_path(path: str) Dict[str, str] [source]¶
Parse a project path into its component segments.
- static parse_queue_path(path: str) Dict[str, str] [source]¶
Parses a queue path into its component segments.
- static parse_task_path(path: str) Dict[str, str] [source]¶
Parses a task path into its component segments.
- pause_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.PauseQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
Pauses the queue.
If a queue is paused then the system will stop dispatching tasks until the queue is resumed via [ResumeQueue][google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue]. Tasks can still be added when the queue is paused. A queue is paused if its [state][google.cloud.tasks.v2beta2.Queue.state] is [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_pause_queue(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.PauseQueueRequest( name="name_value", ) # Make the request response = client.pause_queue(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.PauseQueueRequest, dict]) – The request object. Request message for [PauseQueue][google.cloud.tasks.v2beta2.CloudTasks.PauseQueue].
name (str) –
Required. The queue name. For example:
projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- purge_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.PurgeQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_purge_queue(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.PurgeQueueRequest( name="name_value", ) # Make the request response = client.purge_queue(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.PurgeQueueRequest, dict]) – The request object. Request message for [PurgeQueue][google.cloud.tasks.v2beta2.CloudTasks.PurgeQueue].
name (str) –
Required. The queue name. For example:
projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- static queue_path(project: str, location: str, queue: str) str [source]¶
Returns a fully-qualified queue string.
- renew_lease(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.RenewLeaseRequest, dict]] = None, *, name: Optional[str] = None, schedule_time: Optional[google.protobuf.timestamp_pb2.Timestamp] = None, lease_duration: Optional[google.protobuf.duration_pb2.Duration] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
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 [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_renew_lease(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.RenewLeaseRequest( name="name_value", ) # Make the request response = client.renew_lease(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.RenewLeaseRequest, dict]) – The request object. Request message for renewing a lease using [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease].
name (str) –
Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.schedule_time (google.protobuf.timestamp_pb2.Timestamp) –
Required. The task’s current schedule time, available in the [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction is to ensure that your worker currently holds the lease.
This corresponds to the
schedule_time
field on therequest
instance; ifrequest
is provided, this should not be set.lease_duration (google.protobuf.duration_pb2.Duration) –
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.This corresponds to the
lease_duration
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- resume_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.ResumeQueueRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
Resume a queue.
This method resumes a queue after it has been [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED] or [DISABLED][google.cloud.tasks.v2beta2.Queue.State.DISABLED]. The state of a queue is stored in the queue’s [state][google.cloud.tasks.v2beta2.Queue.state]; after calling this method it will be set to [RUNNING][google.cloud.tasks.v2beta2.Queue.State.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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_resume_queue(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.ResumeQueueRequest( name="name_value", ) # Make the request response = client.resume_queue(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.ResumeQueueRequest, dict]) – The request object. Request message for [ResumeQueue][google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue].
name (str) –
Required. The queue name. For example:
projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- run_task(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.RunTaskRequest, dict]] = None, *, name: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.task.Task [source]¶
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][google.cloud.tasks.v2beta2.RateLimits] or is [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED].
This command is meant to be used for manual debugging. For example, [RunTask][google.cloud.tasks.v2beta2.CloudTasks.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][google.cloud.tasks.v2beta2.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][google.cloud.tasks.v2beta2.Task.schedule_time] will be reset to the time that [RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] was called plus the retry delay specified in the queue’s [RetryConfig][google.cloud.tasks.v2beta2.RetryConfig].
[RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] returns [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded or permanently failed.
[RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] cannot be called on a [pull task][google.cloud.tasks.v2beta2.PullMessage].
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_run_task(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.RunTaskRequest( name="name_value", ) # Make the request response = client.run_task(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.RunTaskRequest, dict]) – The request object. Request message for forcing a task to run now using [RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask].
name (str) –
Required. The task name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID
This corresponds to the
name
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A unit of scheduled work.
- Return type
- set_iam_policy(request: Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]] = None, *, resource: Optional[str] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.policy_pb2.Policy [source]¶
Sets the access control policy for a [Queue][google.cloud.tasks.v2beta2.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
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request response = client.set_iam_policy(request=request) # Handle the response print(response)
- Parameters
request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]) – The request object. Request message for
SetIamPolicy
method.resource (str) –
REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
- An Identity and Access Management (IAM) policy, which specifies access
controls for Google Cloud resources.
A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role.
For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
JSON example:
` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }
`YAML example:
` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3
`For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
- Return type
google.iam.v1.policy_pb2.Policy
- static task_path(project: str, location: str, queue: str, task: str) str [source]¶
Returns a fully-qualified task string.
- test_iam_permissions(request: Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, *, resource: Optional[str] = None, permissions: Optional[MutableSequence[str]] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse [source]¶
Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta2.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.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value1', 'permissions_value2'], ) # Make the request response = client.test_iam_permissions(request=request) # Handle the response print(response)
- Parameters
request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]) – The request object. Request message for
TestIamPermissions
method.resource (str) –
REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
This corresponds to the
resource
field on therequest
instance; ifrequest
is provided, this should not be set.permissions (MutableSequence[str]) –
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.This corresponds to the
permissions
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
Response message for TestIamPermissions method.
- Return type
google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse
- property transport: google.cloud.tasks_v2beta2.services.cloud_tasks.transports.base.CloudTasksTransport¶
Returns the transport used by the client instance.
- Returns
- The transport used by the client
instance.
- Return type
CloudTasksTransport
- property universe_domain: str¶
Return the universe domain used by the client instance.
- Returns
The universe domain used by the client instance.
- Return type
- update_queue(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.UpdateQueueRequest, dict]] = None, *, queue: Optional[google.cloud.tasks_v2beta2.types.queue.Queue] = None, update_mask: Optional[google.protobuf.field_mask_pb2.FieldMask] = None, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.cloud.tasks_v2beta2.types.queue.Queue [source]¶
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
orqueue.xml
file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_update_queue(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.UpdateQueueRequest( ) # Make the request response = client.update_queue(request=request) # Handle the response print(response)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.UpdateQueueRequest, dict]) – The request object. Request message for [UpdateQueue][google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue].
queue (google.cloud.tasks_v2beta2.types.Queue) –
Required. The queue to create or update.
The queue’s [name][google.cloud.tasks.v2beta2.Queue.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][google.cloud.tasks.v2beta2.Queue.name] cannot be changed.
This corresponds to the
queue
field on therequest
instance; ifrequest
is provided, this should not be set.update_mask (google.protobuf.field_mask_pb2.FieldMask) –
A mask used to specify which fields of the queue are being updated. If empty, then all fields will be updated.
This corresponds to the
update_mask
field on therequest
instance; ifrequest
is provided, this should not be set.retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- Returns
A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
- Return type
- upload_queue_yaml(request: Optional[Union[google.cloud.tasks_v2beta2.types.cloudtasks.UploadQueueYamlRequest, dict]] = None, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None [source]¶
Update queue list by uploading a queue.yaml file.
The queue.yaml file is supplied in the request body as a YAML encoded string. This method was added to support gcloud clients versions before 322.0.0. New clients should use CreateQueue instead of this method.
# This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import tasks_v2beta2 def sample_upload_queue_yaml(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) request = tasks_v2beta2.UploadQueueYamlRequest( app_id="app_id_value", ) # Make the request client.upload_queue_yaml(request=request)
- Parameters
request (Union[google.cloud.tasks_v2beta2.types.UploadQueueYamlRequest, dict]) – The request object. Request message for [UploadQueueYaml][google.cloud.tasks.v2beta2.CloudTasks.UploadQueueYaml].
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesAsyncPager(method: Callable[[...], Awaitable[google.cloud.tasks_v2beta2.types.cloudtasks.ListQueuesResponse]], request: google.cloud.tasks_v2beta2.types.cloudtasks.ListQueuesRequest, response: google.cloud.tasks_v2beta2.types.cloudtasks.ListQueuesResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
list_queues
requests.This class thinly wraps an initial
google.cloud.tasks_v2beta2.types.ListQueuesResponse
object, and provides an__aiter__
method to iterate through itsqueues
field.If there are more pages, the
__aiter__
method will make additionalListQueues
requests and continue to iterate through thequeues
field on the corresponding responses.All the usual
google.cloud.tasks_v2beta2.types.ListQueuesResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiates the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.tasks_v2beta2.types.ListQueuesRequest) – The initial request object.
response (google.cloud.tasks_v2beta2.types.ListQueuesResponse) – The initial response object.
retry (google.api_core.retry.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesPager(method: Callable[[...], google.cloud.tasks_v2beta2.types.cloudtasks.ListQueuesResponse], request: google.cloud.tasks_v2beta2.types.cloudtasks.ListQueuesRequest, response: google.cloud.tasks_v2beta2.types.cloudtasks.ListQueuesResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
list_queues
requests.This class thinly wraps an initial
google.cloud.tasks_v2beta2.types.ListQueuesResponse
object, and provides an__iter__
method to iterate through itsqueues
field.If there are more pages, the
__iter__
method will make additionalListQueues
requests and continue to iterate through thequeues
field on the corresponding responses.All the usual
google.cloud.tasks_v2beta2.types.ListQueuesResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiate the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.tasks_v2beta2.types.ListQueuesRequest) – The initial request object.
response (google.cloud.tasks_v2beta2.types.ListQueuesResponse) – The initial response object.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksAsyncPager(method: Callable[[...], Awaitable[google.cloud.tasks_v2beta2.types.cloudtasks.ListTasksResponse]], request: google.cloud.tasks_v2beta2.types.cloudtasks.ListTasksRequest, response: google.cloud.tasks_v2beta2.types.cloudtasks.ListTasksResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary_async.AsyncRetry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
list_tasks
requests.This class thinly wraps an initial
google.cloud.tasks_v2beta2.types.ListTasksResponse
object, and provides an__aiter__
method to iterate through itstasks
field.If there are more pages, the
__aiter__
method will make additionalListTasks
requests and continue to iterate through thetasks
field on the corresponding responses.All the usual
google.cloud.tasks_v2beta2.types.ListTasksResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiates the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.tasks_v2beta2.types.ListTasksRequest) – The initial request object.
response (google.cloud.tasks_v2beta2.types.ListTasksResponse) – The initial response object.
retry (google.api_core.retry.AsyncRetry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.
- class google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksPager(method: Callable[[...], google.cloud.tasks_v2beta2.types.cloudtasks.ListTasksResponse], request: google.cloud.tasks_v2beta2.types.cloudtasks.ListTasksRequest, response: google.cloud.tasks_v2beta2.types.cloudtasks.ListTasksResponse, *, retry: Optional[Union[google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault]] = _MethodDefault._DEFAULT_VALUE, timeout: Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ())[source]¶
A pager for iterating through
list_tasks
requests.This class thinly wraps an initial
google.cloud.tasks_v2beta2.types.ListTasksResponse
object, and provides an__iter__
method to iterate through itstasks
field.If there are more pages, the
__iter__
method will make additionalListTasks
requests and continue to iterate through thetasks
field on the corresponding responses.All the usual
google.cloud.tasks_v2beta2.types.ListTasksResponse
attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.Instantiate the pager.
- Parameters
method (Callable) – The method that was originally called, and which instantiated this pager.
request (google.cloud.tasks_v2beta2.types.ListTasksRequest) – The initial request object.
response (google.cloud.tasks_v2beta2.types.ListTasksResponse) – The initial response object.
retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.
timeout (float) – The timeout for this request.
metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.