Class CloudTasksClient (2.35.0)
Stay organized with collections
Save and categorize content based on your preferences.
- 2.80.0 (latest)
- 2.78.0
- 2.76.0
- 2.75.0
- 2.74.0
- 2.73.0
- 2.72.0
- 2.70.0
- 2.68.0
- 2.67.0
- 2.64.0
- 2.63.0
- 2.62.0
- 2.60.0
- 2.59.0
- 2.58.0
- 2.57.0
- 2.56.0
- 2.55.0
- 2.54.0
- 2.53.0
- 2.52.0
- 2.51.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.40.0
- 2.39.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.28.0
- 2.27.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.12
- 2.2.0
- 2.1.11
Service Description: Cloud Tasks allows developers to manage the execution of background work in their applications.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNamename=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
Queueresponse=cloudTasksClient.getQueue(name);
}
Note: close() needs to be called on the CloudTasksClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
ListQueues |
Lists queues. Queues are returned in lexicographical order. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetQueue |
Gets a queue. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateQueue |
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 |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateQueue |
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 |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteQueue |
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 |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
PurgeQueue |
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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
PauseQueue |
Pauses the queue. If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ResumeQueue |
Resume a queue. This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING. WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in Managing Cloud Tasks Scaling Risks. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UploadQueueYaml |
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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIamPolicy |
Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set. Authorization requires the following Google IAM permission on the specified resource parent:
|
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SetIamPolicy |
Sets the access control policy for a Queue. Replaces any existing policy. Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console. Authorization requires the following Google IAM permission on the specified resource parent:
|
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND 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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListTasks |
Lists the tasks in a queue. By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned. The tasks may be returned in any order. The ordering may change at any time. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetTask |
Gets a task. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateTask |
Creates a task and adds it to a queue. Tasks cannot be updated after creation; there is no UpdateTask command.
|
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteTask |
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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
LeaseTasks |
Leases tasks from a pull queue for lease_duration. This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via AcknowledgeTask after they have performed the work associated with the task. The 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, set response_view to FULL. A maximum of 10 qps of LeaseTasks requests are allowed per queue. RESOURCE_EXHAUSTED is returned when this limit is exceeded. RESOURCE_EXHAUSTED is also returned when max_tasks_dispatched_per_second is exceeded. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
AcknowledgeTask |
Acknowledges a pull task. The worker, that is, the entity that leased this task must call this method to indicate that the work associated with the task has finished. The worker must acknowledge a task within the 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, GetTask, or ListTasks. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RenewLease |
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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CancelLease |
Cancel a pull task's lease. The worker can use this method to cancel a task's lease by setting its schedule_time to now. This will make the task available to be leased to the next caller of LeaseTasks. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RunTask |
Forces a task to run now. When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED. This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now. The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target. If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig. RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed. RunTask cannot be called on a pull task. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of CloudTasksSettings to create(). For example:
To customize credentials:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
CloudTasksSettingscloudTasksSettings=
CloudTasksSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudTasksClientcloudTasksClient=CloudTasksClient.create(cloudTasksSettings);
To customize the endpoint:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
CloudTasksSettingscloudTasksSettings=
CloudTasksSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudTasksClientcloudTasksClient=CloudTasksClient.create(cloudTasksSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
CloudTasksSettingscloudTasksSettings=CloudTasksSettings.newHttpJsonBuilder().build();
CloudTasksClientcloudTasksClient=CloudTasksClient.create(cloudTasksSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
publicstaticfinalCloudTasksClientcreate()Constructs an instance of CloudTasksClient with default settings.
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(CloudTasksSettings settings)
publicstaticfinalCloudTasksClientcreate(CloudTasksSettingssettings)Constructs an instance of CloudTasksClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
| Parameter | |
|---|---|
| Name | Description |
settings |
CloudTasksSettings |
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(CloudTasksStub stub)
publicstaticfinalCloudTasksClientcreate(CloudTasksStubstub)Constructs an instance of CloudTasksClient, using the given stub for making calls. This is for advanced usage - prefer using create(CloudTasksSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
CloudTasksStub |
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient |
|
Constructors
CloudTasksClient(CloudTasksSettings settings)
protectedCloudTasksClient(CloudTasksSettingssettings)Constructs an instance of CloudTasksClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
| Parameter | |
|---|---|
| Name | Description |
settings |
CloudTasksSettings |
CloudTasksClient(CloudTasksStub stub)
protectedCloudTasksClient(CloudTasksStubstub)| Parameter | |
|---|---|
| Name | Description |
stub |
CloudTasksStub |
Methods
acknowledgeTask(AcknowledgeTaskRequest request)
publicfinalvoidacknowledgeTask(AcknowledgeTaskRequestrequest)Acknowledges a pull task.
The worker, that is, the entity that leased this task must call this method to indicate that the work associated with the task has finished.
The worker must acknowledge a task within the 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, GetTask, or ListTasks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
AcknowledgeTaskRequestrequest=
AcknowledgeTaskRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.setScheduleTime(Timestamp.newBuilder().build())
.build();
cloudTasksClient.acknowledgeTask(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
AcknowledgeTaskRequest The request object containing all of the parameters for the API call. |
acknowledgeTask(TaskName name, Timestamp scheduleTime)
publicfinalvoidacknowledgeTask(TaskNamename,TimestampscheduleTime)Acknowledges a pull task.
The worker, that is, the entity that leased this task must call this method to indicate that the work associated with the task has finished.
The worker must acknowledge a task within the 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, GetTask, or ListTasks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
TaskNamename=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]");
TimestampscheduleTime=Timestamp.newBuilder().build();
cloudTasksClient.acknowledgeTask(name,scheduleTime);
}
| Parameters | |
|---|---|
| Name | Description |
name |
TaskName Required. The task name. For example:
|
scheduleTime |
Timestamp Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. |
acknowledgeTask(String name, Timestamp scheduleTime)
publicfinalvoidacknowledgeTask(Stringname,TimestampscheduleTime)Acknowledges a pull task.
The worker, that is, the entity that leased this task must call this method to indicate that the work associated with the task has finished.
The worker must acknowledge a task within the 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, GetTask, or ListTasks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString();
TimestampscheduleTime=Timestamp.newBuilder().build();
cloudTasksClient.acknowledgeTask(name,scheduleTime);
}
| Parameters | |
|---|---|
| Name | Description |
name |
String Required. The task name. For example:
|
scheduleTime |
Timestamp Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. |
acknowledgeTaskCallable()
publicfinalUnaryCallable<AcknowledgeTaskRequest,Empty>acknowledgeTaskCallable()Acknowledges a pull task.
The worker, that is, the entity that leased this task must call this method to indicate that the work associated with the task has finished.
The worker must acknowledge a task within the 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, GetTask, or ListTasks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
AcknowledgeTaskRequestrequest=
AcknowledgeTaskRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.setScheduleTime(Timestamp.newBuilder().build())
.build();
ApiFuture<Empty>future=cloudTasksClient.acknowledgeTaskCallable().futureCall(request);
// Do something.
future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<AcknowledgeTaskRequest,Empty> |
|
awaitTermination(long duration, TimeUnit unit)
publicbooleanawaitTermination(longduration,TimeUnitunit)| Parameters | |
|---|---|
| Name | Description |
duration |
long |
unit |
TimeUnit |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
InterruptedException |
|
cancelLease(CancelLeaseRequest request)
publicfinalTaskcancelLease(CancelLeaseRequestrequest)Cancel a pull task's lease.
The worker can use this method to cancel a task's lease by setting its schedule_time to now. This will make the task available to be leased to the next caller of LeaseTasks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
CancelLeaseRequestrequest=
CancelLeaseRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.setScheduleTime(Timestamp.newBuilder().build())
.build();
Taskresponse=cloudTasksClient.cancelLease(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
CancelLeaseRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
cancelLease(TaskName name, Timestamp scheduleTime)
publicfinalTaskcancelLease(TaskNamename,TimestampscheduleTime)Cancel a pull task's lease.
The worker can use this method to cancel a task's lease by setting its schedule_time to now. This will make the task available to be leased to the next caller of LeaseTasks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
TaskNamename=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]");
TimestampscheduleTime=Timestamp.newBuilder().build();
Taskresponse=cloudTasksClient.cancelLease(name,scheduleTime);
}
| Parameters | |
|---|---|
| Name | Description |
name |
TaskName Required. The task name. For example:
|
scheduleTime |
Timestamp Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
cancelLease(String name, Timestamp scheduleTime)
publicfinalTaskcancelLease(Stringname,TimestampscheduleTime)Cancel a pull task's lease.
The worker can use this method to cancel a task's lease by setting its schedule_time to now. This will make the task available to be leased to the next caller of LeaseTasks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString();
TimestampscheduleTime=Timestamp.newBuilder().build();
Taskresponse=cloudTasksClient.cancelLease(name,scheduleTime);
}
| Parameters | |
|---|---|
| Name | Description |
name |
String Required. The task name. For example:
|
scheduleTime |
Timestamp Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
cancelLeaseCallable()
publicfinalUnaryCallable<CancelLeaseRequest,Task>cancelLeaseCallable()Cancel a pull task's lease.
The worker can use this method to cancel a task's lease by setting its schedule_time to now. This will make the task available to be leased to the next caller of LeaseTasks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
CancelLeaseRequestrequest=
CancelLeaseRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.setScheduleTime(Timestamp.newBuilder().build())
.build();
ApiFuture<Task>future=cloudTasksClient.cancelLeaseCallable().futureCall(request);
// Do something.
Taskresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<CancelLeaseRequest,Task> |
|
close()
publicfinalvoidclose()createQueue(CreateQueueRequest request)
publicfinalQueuecreateQueue(CreateQueueRequestrequest)Creates a queue.
Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
CreateQueueRequestrequest=
CreateQueueRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setQueue(Queue.newBuilder().build())
.build();
Queueresponse=cloudTasksClient.createQueue(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
CreateQueueRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
createQueue(LocationName parent, Queue queue)
publicfinalQueuecreateQueue(LocationNameparent,Queuequeue)Creates a queue.
Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
Queuequeue=Queue.newBuilder().build();
Queueresponse=cloudTasksClient.createQueue(parent,queue);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
LocationName Required. The location name in which the queue will be created. For example:
The list of allowed locations can be obtained by calling Cloud Tasks' implementation of ListLocations. |
queue |
Queue Required. The queue to create. Queue's name cannot be the same as an existing queue. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
createQueue(String parent, Queue queue)
publicfinalQueuecreateQueue(Stringparent,Queuequeue)Creates a queue.
Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringparent=LocationName.of("[PROJECT]","[LOCATION]").toString();
Queuequeue=Queue.newBuilder().build();
Queueresponse=cloudTasksClient.createQueue(parent,queue);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
String Required. The location name in which the queue will be created. For example:
The list of allowed locations can be obtained by calling Cloud Tasks' implementation of ListLocations. |
queue |
Queue Required. The queue to create. Queue's name cannot be the same as an existing queue. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
createQueueCallable()
publicfinalUnaryCallable<CreateQueueRequest,Queue>createQueueCallable()Creates a queue.
Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
CreateQueueRequestrequest=
CreateQueueRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setQueue(Queue.newBuilder().build())
.build();
ApiFuture<Queue>future=cloudTasksClient.createQueueCallable().futureCall(request);
// Do something.
Queueresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<CreateQueueRequest,Queue> |
|
createTask(CreateTaskRequest request)
publicfinalTaskcreateTask(CreateTaskRequestrequest)Creates a task and adds it to a queue.
Tasks cannot be updated after creation; there is no UpdateTask command.
- For App Engine queues, the maximum task size is 100KB.
- For pull queues, the maximum task size is 1MB.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
CreateTaskRequestrequest=
CreateTaskRequest.newBuilder()
.setParent(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setTask(Task.newBuilder().build())
.build();
Taskresponse=cloudTasksClient.createTask(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
CreateTaskRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
createTask(QueueName parent, Task task)
publicfinalTaskcreateTask(QueueNameparent,Tasktask)Creates a task and adds it to a queue.
Tasks cannot be updated after creation; there is no UpdateTask command.
- For App Engine queues, the maximum task size is 100KB.
- For pull queues, the maximum task size is 1MB.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNameparent=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
Tasktask=Task.newBuilder().build();
Taskresponse=cloudTasksClient.createTask(parent,task);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
QueueName Required. The queue name. For example:
The queue must already exist. |
task |
Task Required. The task to add. Task names have the following format:
If schedule_time is not set or is in the past then Cloud Tasks will set it to the current time. Task De-duplication: Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical to that of an existing task or a task that was deleted or completed recently then the call will fail with 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 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. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
createTask(String parent, Task task)
publicfinalTaskcreateTask(Stringparent,Tasktask)Creates a task and adds it to a queue.
Tasks cannot be updated after creation; there is no UpdateTask command.
- For App Engine queues, the maximum task size is 100KB.
- For pull queues, the maximum task size is 1MB.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringparent=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString();
Tasktask=Task.newBuilder().build();
Taskresponse=cloudTasksClient.createTask(parent,task);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
String Required. The queue name. For example:
The queue must already exist. |
task |
Task Required. The task to add. Task names have the following format:
If schedule_time is not set or is in the past then Cloud Tasks will set it to the current time. Task De-duplication: Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical to that of an existing task or a task that was deleted or completed recently then the call will fail with 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 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. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
createTaskCallable()
publicfinalUnaryCallable<CreateTaskRequest,Task>createTaskCallable()Creates a task and adds it to a queue.
Tasks cannot be updated after creation; there is no UpdateTask command.
- For App Engine queues, the maximum task size is 100KB.
- For pull queues, the maximum task size is 1MB.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
CreateTaskRequestrequest=
CreateTaskRequest.newBuilder()
.setParent(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setTask(Task.newBuilder().build())
.build();
ApiFuture<Task>future=cloudTasksClient.createTaskCallable().futureCall(request);
// Do something.
Taskresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<CreateTaskRequest,Task> |
|
deleteQueue(DeleteQueueRequest request)
publicfinalvoiddeleteQueue(DeleteQueueRequestrequest)Deletes a queue.
This command will delete the queue even if it has tasks in it.
Note: If you delete a queue, a queue with the same name can't be created for 7 days.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
DeleteQueueRequestrequest=
DeleteQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.build();
cloudTasksClient.deleteQueue(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
DeleteQueueRequest The request object containing all of the parameters for the API call. |
deleteQueue(QueueName name)
publicfinalvoiddeleteQueue(QueueNamename)Deletes a queue.
This command will delete the queue even if it has tasks in it.
Note: If you delete a queue, a queue with the same name can't be created for 7 days.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNamename=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
cloudTasksClient.deleteQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
QueueName Required. The queue name. For example:
|
deleteQueue(String name)
publicfinalvoiddeleteQueue(Stringname)Deletes a queue.
This command will delete the queue even if it has tasks in it.
Note: If you delete a queue, a queue with the same name can't be created for 7 days.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString();
cloudTasksClient.deleteQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The queue name. For example:
|
deleteQueueCallable()
publicfinalUnaryCallable<DeleteQueueRequest,Empty>deleteQueueCallable()Deletes a queue.
This command will delete the queue even if it has tasks in it.
Note: If you delete a queue, a queue with the same name can't be created for 7 days.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
DeleteQueueRequestrequest=
DeleteQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.build();
ApiFuture<Empty>future=cloudTasksClient.deleteQueueCallable().futureCall(request);
// Do something.
future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<DeleteQueueRequest,Empty> |
|
deleteTask(DeleteTaskRequest request)
publicfinalvoiddeleteTask(DeleteTaskRequestrequest)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
DeleteTaskRequestrequest=
DeleteTaskRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.build();
cloudTasksClient.deleteTask(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
DeleteTaskRequest The request object containing all of the parameters for the API call. |
deleteTask(TaskName name)
publicfinalvoiddeleteTask(TaskNamename)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
TaskNamename=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]");
cloudTasksClient.deleteTask(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
TaskName Required. The task name. For example:
|
deleteTask(String name)
publicfinalvoiddeleteTask(Stringname)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString();
cloudTasksClient.deleteTask(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The task name. For example:
|
deleteTaskCallable()
publicfinalUnaryCallable<DeleteTaskRequest,Empty>deleteTaskCallable()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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
DeleteTaskRequestrequest=
DeleteTaskRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.build();
ApiFuture<Empty>future=cloudTasksClient.deleteTaskCallable().futureCall(request);
// Do something.
future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<DeleteTaskRequest,Empty> |
|
getIamPolicy(ResourceName resource)
publicfinalPolicygetIamPolicy(ResourceNameresource)Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set.
Authorization requires the following Google IAM permission on the specified resource parent:
cloudtasks.queues.getIamPolicy
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ResourceNameresource=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
Policyresponse=cloudTasksClient.getIamPolicy(resource);
}
| Parameter | |
|---|---|
| Name | Description |
resource |
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
getIamPolicy(QueueName queueName)
publicfinalPolicygetIamPolicy(QueueNamequeueName)| Parameter | |
|---|---|
| Name | Description |
queueName |
QueueName |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
getIamPolicy(GetIamPolicyRequest request)
publicfinalPolicygetIamPolicy(GetIamPolicyRequestrequest)Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set.
Authorization requires the following Google IAM permission on the specified resource parent:
cloudtasks.queues.getIamPolicy
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
GetIamPolicyRequestrequest=
GetIamPolicyRequest.newBuilder()
.setResource(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policyresponse=cloudTasksClient.getIamPolicy(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.iam.v1.GetIamPolicyRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
getIamPolicy(String resource)
publicfinalPolicygetIamPolicy(Stringresource)Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set.
Authorization requires the following Google IAM permission on the specified resource parent:
cloudtasks.queues.getIamPolicy
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringresource=LocationName.of("[PROJECT]","[LOCATION]").toString();
Policyresponse=cloudTasksClient.getIamPolicy(resource);
}
| Parameter | |
|---|---|
| Name | Description |
resource |
String REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
getIamPolicyCallable()
publicfinalUnaryCallable<GetIamPolicyRequest,Policy>getIamPolicyCallable()Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set.
Authorization requires the following Google IAM permission on the specified resource parent:
cloudtasks.queues.getIamPolicy
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
GetIamPolicyRequestrequest=
GetIamPolicyRequest.newBuilder()
.setResource(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy>future=cloudTasksClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policyresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
|
getLocation(GetLocationRequest request)
publicfinalLocationgetLocation(GetLocationRequestrequest)Gets information about a location.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
GetLocationRequestrequest=GetLocationRequest.newBuilder().setName("name3373707").build();
Locationresponse=cloudTasksClient.getLocation(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.cloud.location.GetLocationRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
com.google.cloud.location.Location |
|
getLocationCallable()
publicfinalUnaryCallable<GetLocationRequest,Location>getLocationCallable()Gets information about a location.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
GetLocationRequestrequest=GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location>future=cloudTasksClient.getLocationCallable().futureCall(request);
// Do something.
Locationresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
|
getQueue(GetQueueRequest request)
publicfinalQueuegetQueue(GetQueueRequestrequest)Gets a queue.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
GetQueueRequestrequest=
GetQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setReadMask(FieldMask.newBuilder().build())
.build();
Queueresponse=cloudTasksClient.getQueue(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetQueueRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
getQueue(QueueName name)
publicfinalQueuegetQueue(QueueNamename)Gets a queue.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNamename=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
Queueresponse=cloudTasksClient.getQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
QueueName Required. The resource name of the queue. For example:
|
| Returns | |
|---|---|
| Type | Description |
Queue |
|
getQueue(String name)
publicfinalQueuegetQueue(Stringname)Gets a queue.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString();
Queueresponse=cloudTasksClient.getQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The resource name of the queue. For example:
|
| Returns | |
|---|---|
| Type | Description |
Queue |
|
getQueueCallable()
publicfinalUnaryCallable<GetQueueRequest,Queue>getQueueCallable()Gets a queue.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
GetQueueRequestrequest=
GetQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setReadMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Queue>future=cloudTasksClient.getQueueCallable().futureCall(request);
// Do something.
Queueresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetQueueRequest,Queue> |
|
getSettings()
publicfinalCloudTasksSettingsgetSettings()| Returns | |
|---|---|
| Type | Description |
CloudTasksSettings |
|
getStub()
publicCloudTasksStubgetStub()| Returns | |
|---|---|
| Type | Description |
CloudTasksStub |
|
getTask(GetTaskRequest request)
publicfinalTaskgetTask(GetTaskRequestrequest)Gets a task.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
GetTaskRequestrequest=
GetTaskRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.build();
Taskresponse=cloudTasksClient.getTask(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetTaskRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
getTask(TaskName name)
publicfinalTaskgetTask(TaskNamename)Gets a task.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
TaskNamename=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]");
Taskresponse=cloudTasksClient.getTask(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
TaskName Required. The task name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Task |
|
getTask(String name)
publicfinalTaskgetTask(Stringname)Gets a task.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString();
Taskresponse=cloudTasksClient.getTask(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The task name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Task |
|
getTaskCallable()
publicfinalUnaryCallable<GetTaskRequest,Task>getTaskCallable()Gets a task.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
GetTaskRequestrequest=
GetTaskRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.build();
ApiFuture<Task>future=cloudTasksClient.getTaskCallable().futureCall(request);
// Do something.
Taskresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetTaskRequest,Task> |
|
isShutdown()
publicbooleanisShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
publicbooleanisTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
leaseTasks(LeaseTasksRequest request)
publicfinalLeaseTasksResponseleaseTasks(LeaseTasksRequestrequest)Leases tasks from a pull queue for lease_duration.
This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via AcknowledgeTask after they have performed the work associated with the task.
The 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, set response_view to FULL.
A maximum of 10 qps of LeaseTasks requests are allowed per queue. RESOURCE_EXHAUSTED is returned when this limit is exceeded. RESOURCE_EXHAUSTED is also returned when max_tasks_dispatched_per_second is exceeded.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
LeaseTasksRequestrequest=
LeaseTasksRequest.newBuilder()
.setParent(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setMaxTasks(-233969421)
.setLeaseDuration(Duration.newBuilder().build())
.setFilter("filter-1274492040")
.build();
LeaseTasksResponseresponse=cloudTasksClient.leaseTasks(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
LeaseTasksRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
LeaseTasksResponse |
|
leaseTasks(QueueName parent, Duration leaseDuration)
publicfinalLeaseTasksResponseleaseTasks(QueueNameparent,DurationleaseDuration)Leases tasks from a pull queue for lease_duration.
This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via AcknowledgeTask after they have performed the work associated with the task.
The 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, set response_view to FULL.
A maximum of 10 qps of LeaseTasks requests are allowed per queue. RESOURCE_EXHAUSTED is returned when this limit is exceeded. RESOURCE_EXHAUSTED is also returned when max_tasks_dispatched_per_second is exceeded.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNameparent=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
DurationleaseDuration=Duration.newBuilder().build();
LeaseTasksResponseresponse=cloudTasksClient.leaseTasks(parent,leaseDuration);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
QueueName Required. The queue name. For example:
|
leaseDuration |
Duration Required. The duration of the lease. Each task returned in the response will
have its schedule_time set to the current
time plus the After the worker has successfully finished the work associated with the task, the worker must call via AcknowledgeTask before the schedule_time. Otherwise the task will be returned to a later LeaseTasks call so that another worker can retry it. The maximum lease duration is 1 week. |
| Returns | |
|---|---|
| Type | Description |
LeaseTasksResponse |
|
leaseTasks(String parent, Duration leaseDuration)
publicfinalLeaseTasksResponseleaseTasks(Stringparent,DurationleaseDuration)Leases tasks from a pull queue for lease_duration.
This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via AcknowledgeTask after they have performed the work associated with the task.
The 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, set response_view to FULL.
A maximum of 10 qps of LeaseTasks requests are allowed per queue. RESOURCE_EXHAUSTED is returned when this limit is exceeded. RESOURCE_EXHAUSTED is also returned when max_tasks_dispatched_per_second is exceeded.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringparent=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString();
DurationleaseDuration=Duration.newBuilder().build();
LeaseTasksResponseresponse=cloudTasksClient.leaseTasks(parent,leaseDuration);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
String Required. The queue name. For example:
|
leaseDuration |
Duration Required. The duration of the lease. Each task returned in the response will
have its schedule_time set to the current
time plus the After the worker has successfully finished the work associated with the task, the worker must call via AcknowledgeTask before the schedule_time. Otherwise the task will be returned to a later LeaseTasks call so that another worker can retry it. The maximum lease duration is 1 week. |
| Returns | |
|---|---|
| Type | Description |
LeaseTasksResponse |
|
leaseTasksCallable()
publicfinalUnaryCallable<LeaseTasksRequest,LeaseTasksResponse>leaseTasksCallable()Leases tasks from a pull queue for lease_duration.
This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via AcknowledgeTask after they have performed the work associated with the task.
The 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, set response_view to FULL.
A maximum of 10 qps of LeaseTasks requests are allowed per queue. RESOURCE_EXHAUSTED is returned when this limit is exceeded. RESOURCE_EXHAUSTED is also returned when max_tasks_dispatched_per_second is exceeded.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
LeaseTasksRequestrequest=
LeaseTasksRequest.newBuilder()
.setParent(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setMaxTasks(-233969421)
.setLeaseDuration(Duration.newBuilder().build())
.setFilter("filter-1274492040")
.build();
ApiFuture<LeaseTasksResponse>future=
cloudTasksClient.leaseTasksCallable().futureCall(request);
// Do something.
LeaseTasksResponseresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<LeaseTasksRequest,LeaseTasksResponse> |
|
listLocations(ListLocationsRequest request)
publicfinalCloudTasksClient.ListLocationsPagedResponselistLocations(ListLocationsRequestrequest)Lists information about the supported locations for this service.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(Locationelement:cloudTasksClient.listLocations(request).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.cloud.location.ListLocationsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient.ListLocationsPagedResponse |
|
listLocationsCallable()
publicfinalUnaryCallable<ListLocationsRequest,ListLocationsResponse>listLocationsCallable()Lists information about the supported locations for this service.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListLocationsResponseresponse=cloudTasksClient.listLocationsCallable().call(request);
for(Locationelement:response.getLocationsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
|
listLocationsPagedCallable()
publicfinalUnaryCallable<ListLocationsRequest,CloudTasksClient.ListLocationsPagedResponse>listLocationsPagedCallable()Lists information about the supported locations for this service.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location>future=
cloudTasksClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for(Locationelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse> |
|
listQueues(ListQueuesRequest request)
publicfinalCloudTasksClient.ListQueuesPagedResponselistQueues(ListQueuesRequestrequest)Lists queues.
Queues are returned in lexicographical order.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListQueuesRequestrequest=
ListQueuesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
for(Queueelement:cloudTasksClient.listQueues(request).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
ListQueuesRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient.ListQueuesPagedResponse |
|
listQueues(LocationName parent)
publicfinalCloudTasksClient.ListQueuesPagedResponselistQueues(LocationNameparent)Lists queues.
Queues are returned in lexicographical order.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
for(Queueelement:cloudTasksClient.listQueues(parent).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
LocationName Required. The location name. For example:
|
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient.ListQueuesPagedResponse |
|
listQueues(String parent)
publicfinalCloudTasksClient.ListQueuesPagedResponselistQueues(Stringparent)Lists queues.
Queues are returned in lexicographical order.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringparent=LocationName.of("[PROJECT]","[LOCATION]").toString();
for(Queueelement:cloudTasksClient.listQueues(parent).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
String Required. The location name. For example:
|
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient.ListQueuesPagedResponse |
|
listQueuesCallable()
publicfinalUnaryCallable<ListQueuesRequest,ListQueuesResponse>listQueuesCallable()Lists queues.
Queues are returned in lexicographical order.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListQueuesRequestrequest=
ListQueuesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
while(true){
ListQueuesResponseresponse=cloudTasksClient.listQueuesCallable().call(request);
for(Queueelement:response.getQueuesList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListQueuesRequest,ListQueuesResponse> |
|
listQueuesPagedCallable()
publicfinalUnaryCallable<ListQueuesRequest,CloudTasksClient.ListQueuesPagedResponse>listQueuesPagedCallable()Lists queues.
Queues are returned in lexicographical order.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListQueuesRequestrequest=
ListQueuesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Queue>future=cloudTasksClient.listQueuesPagedCallable().futureCall(request);
// Do something.
for(Queueelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListQueuesRequest,ListQueuesPagedResponse> |
|
listTasks(ListTasksRequest request)
publicfinalCloudTasksClient.ListTasksPagedResponselistTasks(ListTasksRequestrequest)Lists the tasks in a queue.
By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned.
The tasks may be returned in any order. The ordering may change at any time.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListTasksRequestrequest=
ListTasksRequest.newBuilder()
.setParent(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(Taskelement:cloudTasksClient.listTasks(request).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
ListTasksRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient.ListTasksPagedResponse |
|
listTasks(QueueName parent)
publicfinalCloudTasksClient.ListTasksPagedResponselistTasks(QueueNameparent)Lists the tasks in a queue.
By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned.
The tasks may be returned in any order. The ordering may change at any time.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNameparent=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
for(Taskelement:cloudTasksClient.listTasks(parent).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
QueueName Required. The queue name. For example:
|
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient.ListTasksPagedResponse |
|
listTasks(String parent)
publicfinalCloudTasksClient.ListTasksPagedResponselistTasks(Stringparent)Lists the tasks in a queue.
By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned.
The tasks may be returned in any order. The ordering may change at any time.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringparent=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString();
for(Taskelement:cloudTasksClient.listTasks(parent).iterateAll()){
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
String Required. The queue name. For example:
|
| Returns | |
|---|---|
| Type | Description |
CloudTasksClient.ListTasksPagedResponse |
|
listTasksCallable()
publicfinalUnaryCallable<ListTasksRequest,ListTasksResponse>listTasksCallable()Lists the tasks in a queue.
By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned.
The tasks may be returned in any order. The ordering may change at any time.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListTasksRequestrequest=
ListTasksRequest.newBuilder()
.setParent(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListTasksResponseresponse=cloudTasksClient.listTasksCallable().call(request);
for(Taskelement:response.getTasksList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListTasksRequest,ListTasksResponse> |
|
listTasksPagedCallable()
publicfinalUnaryCallable<ListTasksRequest,CloudTasksClient.ListTasksPagedResponse>listTasksPagedCallable()Lists the tasks in a queue.
By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned.
The tasks may be returned in any order. The ordering may change at any time.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ListTasksRequestrequest=
ListTasksRequest.newBuilder()
.setParent(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Task>future=cloudTasksClient.listTasksPagedCallable().futureCall(request);
// Do something.
for(Taskelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListTasksRequest,ListTasksPagedResponse> |
|
pauseQueue(PauseQueueRequest request)
publicfinalQueuepauseQueue(PauseQueueRequestrequest)Pauses the queue.
If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
PauseQueueRequestrequest=
PauseQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.build();
Queueresponse=cloudTasksClient.pauseQueue(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
PauseQueueRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
pauseQueue(QueueName name)
publicfinalQueuepauseQueue(QueueNamename)Pauses the queue.
If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNamename=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
Queueresponse=cloudTasksClient.pauseQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
QueueName Required. The queue name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Queue |
|
pauseQueue(String name)
publicfinalQueuepauseQueue(Stringname)Pauses the queue.
If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString();
Queueresponse=cloudTasksClient.pauseQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The queue name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Queue |
|
pauseQueueCallable()
publicfinalUnaryCallable<PauseQueueRequest,Queue>pauseQueueCallable()Pauses the queue.
If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
PauseQueueRequestrequest=
PauseQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.build();
ApiFuture<Queue>future=cloudTasksClient.pauseQueueCallable().futureCall(request);
// Do something.
Queueresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<PauseQueueRequest,Queue> |
|
purgeQueue(PurgeQueueRequest request)
publicfinalQueuepurgeQueue(PurgeQueueRequestrequest)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
PurgeQueueRequestrequest=
PurgeQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.build();
Queueresponse=cloudTasksClient.purgeQueue(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
PurgeQueueRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
purgeQueue(QueueName name)
publicfinalQueuepurgeQueue(QueueNamename)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNamename=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
Queueresponse=cloudTasksClient.purgeQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
QueueName Required. The queue name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Queue |
|
purgeQueue(String name)
publicfinalQueuepurgeQueue(Stringname)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString();
Queueresponse=cloudTasksClient.purgeQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The queue name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Queue |
|
purgeQueueCallable()
publicfinalUnaryCallable<PurgeQueueRequest,Queue>purgeQueueCallable()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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
PurgeQueueRequestrequest=
PurgeQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.build();
ApiFuture<Queue>future=cloudTasksClient.purgeQueueCallable().futureCall(request);
// Do something.
Queueresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<PurgeQueueRequest,Queue> |
|
renewLease(RenewLeaseRequest request)
publicfinalTaskrenewLease(RenewLeaseRequestrequest)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
RenewLeaseRequestrequest=
RenewLeaseRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.setScheduleTime(Timestamp.newBuilder().build())
.setLeaseDuration(Duration.newBuilder().build())
.build();
Taskresponse=cloudTasksClient.renewLease(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
RenewLeaseRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
renewLease(TaskName name, Timestamp scheduleTime, Duration leaseDuration)
publicfinalTaskrenewLease(TaskNamename,TimestampscheduleTime,DurationleaseDuration)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
TaskNamename=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]");
TimestampscheduleTime=Timestamp.newBuilder().build();
DurationleaseDuration=Duration.newBuilder().build();
Taskresponse=cloudTasksClient.renewLease(name,scheduleTime,leaseDuration);
}
| Parameters | |
|---|---|
| Name | Description |
name |
TaskName Required. The task name. For example:
|
scheduleTime |
Timestamp Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. |
leaseDuration |
Duration Required. The desired new lease duration, starting from now. The maximum lease duration is 1 week. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
renewLease(String name, Timestamp scheduleTime, Duration leaseDuration)
publicfinalTaskrenewLease(Stringname,TimestampscheduleTime,DurationleaseDuration)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString();
TimestampscheduleTime=Timestamp.newBuilder().build();
DurationleaseDuration=Duration.newBuilder().build();
Taskresponse=cloudTasksClient.renewLease(name,scheduleTime,leaseDuration);
}
| Parameters | |
|---|---|
| Name | Description |
name |
String Required. The task name. For example:
|
scheduleTime |
Timestamp Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. |
leaseDuration |
Duration Required. The desired new lease duration, starting from now. The maximum lease duration is 1 week. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
renewLeaseCallable()
publicfinalUnaryCallable<RenewLeaseRequest,Task>renewLeaseCallable()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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
RenewLeaseRequestrequest=
RenewLeaseRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.setScheduleTime(Timestamp.newBuilder().build())
.setLeaseDuration(Duration.newBuilder().build())
.build();
ApiFuture<Task>future=cloudTasksClient.renewLeaseCallable().futureCall(request);
// Do something.
Taskresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<RenewLeaseRequest,Task> |
|
resumeQueue(QueueName name)
publicfinalQueueresumeQueue(QueueNamename)Resume a queue.
This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING.
WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in Managing Cloud Tasks Scaling Risks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
QueueNamename=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
Queueresponse=cloudTasksClient.resumeQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
QueueName Required. The queue name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Queue |
|
resumeQueue(ResumeQueueRequest request)
publicfinalQueueresumeQueue(ResumeQueueRequestrequest)Resume a queue.
This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING.
WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in Managing Cloud Tasks Scaling Risks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ResumeQueueRequestrequest=
ResumeQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.build();
Queueresponse=cloudTasksClient.resumeQueue(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
ResumeQueueRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
resumeQueue(String name)
publicfinalQueueresumeQueue(Stringname)Resume a queue.
This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING.
WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in Managing Cloud Tasks Scaling Risks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString();
Queueresponse=cloudTasksClient.resumeQueue(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The queue name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Queue |
|
resumeQueueCallable()
publicfinalUnaryCallable<ResumeQueueRequest,Queue>resumeQueueCallable()Resume a queue.
This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING.
WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in Managing Cloud Tasks Scaling Risks.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ResumeQueueRequestrequest=
ResumeQueueRequest.newBuilder()
.setName(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.build();
ApiFuture<Queue>future=cloudTasksClient.resumeQueueCallable().futureCall(request);
// Do something.
Queueresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ResumeQueueRequest,Queue> |
|
runTask(RunTaskRequest request)
publicfinalTaskrunTask(RunTaskRequestrequest)Forces a task to run now.
When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED.
This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now.
The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target.
If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig.
RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed.
RunTask cannot be called on a pull task.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
RunTaskRequestrequest=
RunTaskRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.build();
Taskresponse=cloudTasksClient.runTask(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
RunTaskRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Task |
|
runTask(TaskName name)
publicfinalTaskrunTask(TaskNamename)Forces a task to run now.
When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED.
This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now.
The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target.
If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig.
RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed.
RunTask cannot be called on a pull task.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
TaskNamename=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]");
Taskresponse=cloudTasksClient.runTask(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
TaskName Required. The task name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Task |
|
runTask(String name)
publicfinalTaskrunTask(Stringname)Forces a task to run now.
When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED.
This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now.
The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target.
If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig.
RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed.
RunTask cannot be called on a pull task.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringname=TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString();
Taskresponse=cloudTasksClient.runTask(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
String Required. The task name. For example:
|
| Returns | |
|---|---|
| Type | Description |
Task |
|
runTaskCallable()
publicfinalUnaryCallable<RunTaskRequest,Task>runTaskCallable()Forces a task to run now.
When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED.
This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now.
The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target.
If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig.
RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed.
RunTask cannot be called on a pull task.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
RunTaskRequestrequest=
RunTaskRequest.newBuilder()
.setName(TaskName.of("[PROJECT]","[LOCATION]","[QUEUE]","[TASK]").toString())
.build();
ApiFuture<Task>future=cloudTasksClient.runTaskCallable().futureCall(request);
// Do something.
Taskresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<RunTaskRequest,Task> |
|
setIamPolicy(ResourceName resource, Policy policy)
publicfinalPolicysetIamPolicy(ResourceNameresource,Policypolicy)Sets the access control policy for a Queue. Replaces any existing policy.
Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console.
Authorization requires the following Google IAM permission on the specified resource parent:
cloudtasks.queues.setIamPolicy
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ResourceNameresource=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
Policypolicy=Policy.newBuilder().build();
Policyresponse=cloudTasksClient.setIamPolicy(resource,policy);
}
| Parameters | |
|---|---|
| Name | Description |
resource |
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy |
com.google.iam.v1.PolicyREQUIRED: The complete policy to be applied to the |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
setIamPolicy(QueueName queue, Policy policy)
publicfinalPolicysetIamPolicy(QueueNamequeue,Policypolicy)| Parameters | |
|---|---|
| Name | Description |
queue |
QueueName |
policy |
com.google.iam.v1.Policy |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
setIamPolicy(SetIamPolicyRequest request)
publicfinalPolicysetIamPolicy(SetIamPolicyRequestrequest)Sets the access control policy for a Queue. Replaces any existing policy.
Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console.
Authorization requires the following Google IAM permission on the specified resource parent:
cloudtasks.queues.setIamPolicy
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
SetIamPolicyRequestrequest=
SetIamPolicyRequest.newBuilder()
.setResource(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policyresponse=cloudTasksClient.setIamPolicy(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.iam.v1.SetIamPolicyRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
setIamPolicy(String resource, Policy policy)
publicfinalPolicysetIamPolicy(Stringresource,Policypolicy)Sets the access control policy for a Queue. Replaces any existing policy.
Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console.
Authorization requires the following Google IAM permission on the specified resource parent:
cloudtasks.queues.setIamPolicy
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringresource=LocationName.of("[PROJECT]","[LOCATION]").toString();
Policypolicy=Policy.newBuilder().build();
Policyresponse=cloudTasksClient.setIamPolicy(resource,policy);
}
| Parameters | |
|---|---|
| Name | Description |
resource |
String REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy |
com.google.iam.v1.PolicyREQUIRED: The complete policy to be applied to the |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
setIamPolicyCallable()
publicfinalUnaryCallable<SetIamPolicyRequest,Policy>setIamPolicyCallable()Sets the access control policy for a Queue. Replaces any existing policy.
Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console.
Authorization requires the following Google IAM permission on the specified resource parent:
cloudtasks.queues.setIamPolicy
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
SetIamPolicyRequestrequest=
SetIamPolicyRequest.newBuilder()
.setResource(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy>future=cloudTasksClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policyresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
|
shutdown()
publicvoidshutdown()shutdownNow()
publicvoidshutdownNow()testIamPermissions(ResourceName resource, List<String> permissions)
publicfinalTestIamPermissionsResponsetestIamPermissions(ResourceNameresource,List<String>permissions)Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND 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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
ResourceNameresource=QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]");
List<String>permissions=newArrayList<>();
TestIamPermissionsResponseresponse=
cloudTasksClient.testIamPermissions(resource,permissions);
}
| Parameters | |
|---|---|
| Name | Description |
resource |
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions |
List<String>The set of permissions to check for the |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
|
testIamPermissions(QueueName queue, List<String> permissions)
publicfinalTestIamPermissionsResponsetestIamPermissions(QueueNamequeue,List<String>permissions)| Parameters | |
|---|---|
| Name | Description |
queue |
QueueName |
permissions |
List<String> |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
|
testIamPermissions(TestIamPermissionsRequest request)
publicfinalTestIamPermissionsResponsetestIamPermissions(TestIamPermissionsRequestrequest)Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND 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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
TestIamPermissionsRequestrequest=
TestIamPermissionsRequest.newBuilder()
.setResource(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.addAllPermissions(newArrayList<String>())
.build();
TestIamPermissionsResponseresponse=cloudTasksClient.testIamPermissions(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.iam.v1.TestIamPermissionsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
|
testIamPermissions(String resource, List<String> permissions)
publicfinalTestIamPermissionsResponsetestIamPermissions(Stringresource,List<String>permissions)Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND 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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Stringresource=LocationName.of("[PROJECT]","[LOCATION]").toString();
List<String>permissions=newArrayList<>();
TestIamPermissionsResponseresponse=
cloudTasksClient.testIamPermissions(resource,permissions);
}
| Parameters | |
|---|---|
| Name | Description |
resource |
String REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions |
List<String>The set of permissions to check for the |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
|
testIamPermissionsCallable()
publicfinalUnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse>testIamPermissionsCallable()Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND 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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
TestIamPermissionsRequestrequest=
TestIamPermissionsRequest.newBuilder()
.setResource(QueueName.of("[PROJECT]","[LOCATION]","[QUEUE]").toString())
.addAllPermissions(newArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse>future=
cloudTasksClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponseresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
|
updateQueue(Queue queue, FieldMask updateMask)
publicfinalQueueupdateQueue(Queuequeue,FieldMaskupdateMask)Updates a queue.
This method creates the queue if it does not exist and updates the queue if it does exist.
Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
Queuequeue=Queue.newBuilder().build();
FieldMaskupdateMask=FieldMask.newBuilder().build();
Queueresponse=cloudTasksClient.updateQueue(queue,updateMask);
}
| Parameters | |
|---|---|
| Name | Description |
queue |
Queue Required. The queue to create or update. The queue's name must be specified. Output only fields cannot be modified using UpdateQueue. Any value specified for an output only field will be ignored. The queue's name cannot be changed. |
updateMask |
FieldMask A mask used to specify which fields of the queue are being updated. If empty, then all fields will be updated. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
updateQueue(UpdateQueueRequest request)
publicfinalQueueupdateQueue(UpdateQueueRequestrequest)Updates a queue.
This method creates the queue if it does not exist and updates the queue if it does exist.
Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
UpdateQueueRequestrequest=
UpdateQueueRequest.newBuilder()
.setQueue(Queue.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Queueresponse=cloudTasksClient.updateQueue(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
UpdateQueueRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Queue |
|
updateQueueCallable()
publicfinalUnaryCallable<UpdateQueueRequest,Queue>updateQueueCallable()Updates a queue.
This method creates the queue if it does not exist and updates the queue if it does exist.
Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
WARNING: Using this method may have unintended side effects if you are using an App Engine
queue.yaml or queue.xml file to manage your queues. Read Overview of Queue Management and
queue.yaml before using this method.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
UpdateQueueRequestrequest=
UpdateQueueRequest.newBuilder()
.setQueue(Queue.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Queue>future=cloudTasksClient.updateQueueCallable().futureCall(request);
// Do something.
Queueresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<UpdateQueueRequest,Queue> |
|
uploadQueueYaml(UploadQueueYamlRequest request)
publicfinalvoiduploadQueueYaml(UploadQueueYamlRequestrequest)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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
UploadQueueYamlRequestrequest=
UploadQueueYamlRequest.newBuilder()
.setAppId("appId93028124")
.setHttpBody(HttpBody.newBuilder().build())
.build();
cloudTasksClient.uploadQueueYaml(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
UploadQueueYamlRequest The request object containing all of the parameters for the API call. |
uploadQueueYamlCallable()
publicfinalUnaryCallable<UploadQueueYamlRequest,Empty>uploadQueueYamlCallable()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.
Sample code:
// 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(CloudTasksClientcloudTasksClient=CloudTasksClient.create()){
UploadQueueYamlRequestrequest=
UploadQueueYamlRequest.newBuilder()
.setAppId("appId93028124")
.setHttpBody(HttpBody.newBuilder().build())
.build();
ApiFuture<Empty>future=cloudTasksClient.uploadQueueYamlCallable().futureCall(request);
// Do something.
future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<UploadQueueYamlRequest,Empty> |
|