diff --git a/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java b/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java index 47eeaf54..1cdaa9ff 100644 --- a/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java +++ b/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java @@ -50,6 +50,13 @@ *
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: * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = 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(). * @@ -153,6 +160,17 @@ public CloudTasksStub getStub() { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * for (Queue element : cloudTasksClient.listQueues(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -169,6 +187,17 @@ public final ListQueuesPagedResponse listQueues(LocationName parent) { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * for (Queue element : cloudTasksClient.listQueues(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -184,6 +213,23 @@ public final ListQueuesPagedResponse listQueues(String parent) { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListQueuesRequest request = + * ListQueuesRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Queue element : cloudTasksClient.listQueues(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -198,6 +244,23 @@ public final ListQueuesPagedResponse listQueues(ListQueuesRequest request) { *
Queues are returned in lexicographical order. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListQueuesRequest request = + * ListQueuesRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.listQueuesPagedCallable().futureCall(request); + * // Do something. + * for (Queue element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Queues are returned in lexicographical order. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * while (true) { + * ListQueuesResponse response = cloudTasksClient.listQueuesCallable().call(request); + * for (Queue element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }*/ public final UnaryCallable
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }+ * * @param name Required. The resource name of the queue. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -233,6 +322,15 @@ public final Queue getQueue(QueueName name) { /** * Gets a queue. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }+ * * @param name Required. The resource name of the queue. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -246,6 +344,18 @@ public final Queue getQueue(String name) { /** * Gets a queue. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetQueueRequest request = + * GetQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.getQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -258,6 +368,18 @@ public final Queue getQueue(GetQueueRequest request) { * Gets a queue. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetQueueRequest request = + * GetQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * Queue queue = Queue.newBuilder().build(); + * Queue response = cloudTasksClient.createQueue(parent, queue); + * } + * }+ * * @param parent Required. The location name in which the queue will be created. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` *
The list of allowed locations can be obtained by calling Cloud Tasks' implementation of @@ -303,6 +435,16 @@ public final Queue createQueue(LocationName parent, Queue queue) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue queue = Queue.newBuilder().build(); + * Queue response = cloudTasksClient.createQueue(parent, queue); + * } + * }+ * * @param parent Required. The location name in which the queue will be created. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` *
The list of allowed locations can be obtained by calling Cloud Tasks' implementation of @@ -329,6 +471,19 @@ public final Queue createQueue(String parent, Queue queue) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateQueueRequest request = + * CreateQueueRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setQueue(Queue.newBuilder().build()) + * .build(); + * Queue response = cloudTasksClient.createQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -348,6 +503,19 @@ public final Queue createQueue(CreateQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateQueueRequest request = + * CreateQueueRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setQueue(Queue.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.createQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * Queue queue = Queue.newBuilder().build(); + * FieldMask updateMask = FieldMask.newBuilder().build(); + * Queue response = cloudTasksClient.updateQueue(queue, updateMask); + * } + * }+ * * @param queue Required. The queue to create or update. *
The queue's [name][google.cloud.tasks.v2.Queue.name] must be specified. *
Output only fields cannot be modified using UpdateQueue. Any value specified for an @@ -394,6 +572,19 @@ public final Queue updateQueue(Queue queue, FieldMask updateMask) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * UpdateQueueRequest request = + * UpdateQueueRequest.newBuilder() + * .setQueue(Queue.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * Queue response = cloudTasksClient.updateQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -415,6 +606,19 @@ public final Queue updateQueue(UpdateQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * UpdateQueueRequest request = + * UpdateQueueRequest.newBuilder() + * .setQueue(Queue.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.updateQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * cloudTasksClient.deleteQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -454,6 +667,15 @@ public final void deleteQueue(QueueName name) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * cloudTasksClient.deleteQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -475,6 +697,18 @@ public final void deleteQueue(String name) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteQueueRequest request = + * DeleteQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * cloudTasksClient.deleteQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -495,6 +729,18 @@ public final void deleteQueue(DeleteQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteQueueRequest request = + * DeleteQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.deleteQueueCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.purgeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -528,6 +783,15 @@ public final Queue purgeQueue(QueueName name) { *
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.purgeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -546,6 +810,18 @@ public final Queue purgeQueue(String name) { *
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PurgeQueueRequest request = + * PurgeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.purgeQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -563,6 +839,18 @@ public final Queue purgeQueue(PurgeQueueRequest request) { * the purge takes effect. A purge is irreversible. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PurgeQueueRequest request = + * PurgeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.purgeQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.pauseQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -596,6 +893,15 @@ public final Queue pauseQueue(QueueName name) { * the queue is paused. A queue is paused if its [state][google.cloud.tasks.v2.Queue.state] is * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.pauseQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -614,6 +920,18 @@ public final Queue pauseQueue(String name) { * the queue is paused. A queue is paused if its [state][google.cloud.tasks.v2.Queue.state] is * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PauseQueueRequest request = + * PauseQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.pauseQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -631,6 +949,18 @@ public final Queue pauseQueue(PauseQueueRequest request) { * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PauseQueueRequest request = + * PauseQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.pauseQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.resumeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -674,6 +1013,15 @@ public final Queue resumeQueue(QueueName name) { * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.resumeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -697,6 +1045,18 @@ public final Queue resumeQueue(String name) { * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResumeQueueRequest request = + * ResumeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.resumeQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -719,6 +1079,18 @@ public final Queue resumeQueue(ResumeQueueRequest request) { * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResumeQueueRequest request = + * ResumeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.resumeQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * Policy response = cloudTasksClient.getIamPolicy(resource); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -760,6 +1141,15 @@ public final Policy getIamPolicy(ResourceName resource) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * Policy response = cloudTasksClient.getIamPolicy(resource); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -781,6 +1171,19 @@ public final Policy getIamPolicy(String resource) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetIamPolicyRequest request = + * GetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setOptions(GetPolicyOptions.newBuilder().build()) + * .build(); + * Policy response = cloudTasksClient.getIamPolicy(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -805,6 +1208,19 @@ public final Policy getIamPolicy(QueueName queueName) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetIamPolicyRequest request = + * GetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setOptions(GetPolicyOptions.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * Policy policy = Policy.newBuilder().build(); + * Policy response = cloudTasksClient.setIamPolicy(resource, policy); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -856,6 +1282,16 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * Policy policy = Policy.newBuilder().build(); + * Policy response = cloudTasksClient.setIamPolicy(resource, policy); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -884,6 +1320,19 @@ public final Policy setIamPolicy(String resource, Policy policy) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * SetIamPolicyRequest request = + * SetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .build(); + * Policy response = cloudTasksClient.setIamPolicy(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -911,6 +1360,19 @@ public final Policy setIamPolicy(QueueName queue, Policy policy) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * SetIamPolicyRequest request = + * SetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.setIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * List+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -953,6 +1426,17 @@ public final TestIamPermissionsResponse testIamPermissions( * command-line tools, not for authorization checking. This operation may "fail open" without * warning. * + *permissions = new ArrayList<>(); + * TestIamPermissionsResponse response = + * cloudTasksClient.testIamPermissions(resource, permissions); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * List+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -980,6 +1464,19 @@ public final TestIamPermissionsResponse testIamPermissions( * command-line tools, not for authorization checking. This operation may "fail open" without * warning. * + *permissions = new ArrayList<>(); + * TestIamPermissionsResponse response = + * cloudTasksClient.testIamPermissions(resource, permissions); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TestIamPermissionsRequest request = + * TestIamPermissionsRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .addAllPermissions(new ArrayList+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1003,6 +1500,20 @@ public final TestIamPermissionsResponse testIamPermissions( * warning. * *()) + * .build(); + * TestIamPermissionsResponse response = cloudTasksClient.testIamPermissions(request); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TestIamPermissionsRequest request = + * TestIamPermissionsRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .addAllPermissions(new ArrayList*/ public final UnaryCallable()) + * .build(); + * ApiFuture future = + * cloudTasksClient.testIamPermissionsCallable().futureCall(request); + * // Do something. + * TestIamPermissionsResponse response = future.get(); + * } + * }
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * for (Task element : cloudTasksClient.listTasks(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1041,6 +1563,17 @@ public final ListTasksPagedResponse listTasks(QueueName parent) { * *
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * for (Task element : cloudTasksClient.listTasks(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1061,6 +1594,22 @@ public final ListTasksPagedResponse listTasks(String parent) { * *
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Task element : cloudTasksClient.listTasks(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1080,6 +1629,22 @@ public final ListTasksPagedResponse listTasks(ListTasksRequest request) { *
The tasks may be returned in any order. The ordering may change at any time. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.listTasksPagedCallable().futureCall(request); + * // Do something. + * for (Task element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
The tasks may be returned in any order. The ordering may change at any time. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * while (true) { + * ListTasksResponse response = cloudTasksClient.listTasksCallable().call(request); + * for (Task element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }*/ public final UnaryCallable
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Task response = cloudTasksClient.getTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1120,6 +1711,15 @@ public final Task getTask(TaskName name) { /** * Gets a task. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task response = cloudTasksClient.getTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1133,6 +1733,18 @@ public final Task getTask(String name) { /** * Gets a task. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetTaskRequest request = + * GetTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * Task response = cloudTasksClient.getTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1145,6 +1757,18 @@ public final Task getTask(GetTaskRequest request) { * Gets a task. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetTaskRequest request = + * GetTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Task task = Task.newBuilder().build(); + * Task response = cloudTasksClient.createTask(parent, task); + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` *
The queue must already exist. @@ -1207,6 +1841,16 @@ public final Task createTask(QueueName parent, Task task) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task task = Task.newBuilder().build(); + * Task response = cloudTasksClient.createTask(parent, task); + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` *
The queue must already exist. @@ -1251,6 +1895,19 @@ public final Task createTask(String parent, Task task) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateTaskRequest request = + * CreateTaskRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setTask(Task.newBuilder().build()) + * .build(); + * Task response = cloudTasksClient.createTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1269,6 +1926,19 @@ public final Task createTask(CreateTaskRequest request) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateTaskRequest request = + * CreateTaskRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setTask(Task.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.createTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has * executed successfully or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * cloudTasksClient.deleteTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1298,6 +1977,15 @@ public final void deleteTask(TaskName name) { *
A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has * executed successfully or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * cloudTasksClient.deleteTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1314,6 +2002,18 @@ public final void deleteTask(String name) { *
A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has * executed successfully or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteTaskRequest request = + * DeleteTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * cloudTasksClient.deleteTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1329,6 +2029,18 @@ public final void deleteTask(DeleteTaskRequest request) { * executed successfully or permanently failed. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteTaskRequest request = + * DeleteTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.deleteTaskCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Task response = cloudTasksClient.runTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1394,6 +2115,15 @@ public final Task runTask(TaskName name) { * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded * or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task response = cloudTasksClient.runTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1428,6 +2158,18 @@ public final Task runTask(String name) { * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded * or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * RunTaskRequest request = + * RunTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * Task response = cloudTasksClient.runTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1461,6 +2203,18 @@ public final Task runTask(RunTaskRequest request) { * or permanently failed. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * RunTaskRequest request = + * RunTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.runTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
Sample for CloudTasksClient: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }*/ @Generated("by gapic-generator-java") package com.google.cloud.tasks.v2; diff --git a/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java b/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java index 549bbc8f..d3896960 100644 --- a/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java +++ b/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java @@ -52,6 +52,13 @@ *
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: * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = 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(). * @@ -156,6 +163,17 @@ public CloudTasksStub getStub() { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * for (Queue element : cloudTasksClient.listQueues(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -172,6 +190,17 @@ public final ListQueuesPagedResponse listQueues(LocationName parent) { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * for (Queue element : cloudTasksClient.listQueues(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -187,6 +216,24 @@ public final ListQueuesPagedResponse listQueues(String parent) { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListQueuesRequest request = + * ListQueuesRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setReadMask(FieldMask.newBuilder().build()) + * .build(); + * for (Queue element : cloudTasksClient.listQueues(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -201,6 +248,24 @@ public final ListQueuesPagedResponse listQueues(ListQueuesRequest request) { *
Queues are returned in lexicographical order. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListQueuesRequest request = + * ListQueuesRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setReadMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.listQueuesPagedCallable().futureCall(request); + * // Do something. + * for (Queue element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Queues are returned in lexicographical order. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * while (true) { + * ListQueuesResponse response = cloudTasksClient.listQueuesCallable().call(request); + * for (Queue element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }*/ public final UnaryCallable
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }+ * * @param name Required. The resource name of the queue. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -236,6 +327,15 @@ public final Queue getQueue(QueueName name) { /** * Gets a queue. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }+ * * @param name Required. The resource name of the queue. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -249,6 +349,19 @@ public final Queue getQueue(String name) { /** * Gets a queue. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetQueueRequest request = + * GetQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setReadMask(FieldMask.newBuilder().build()) + * .build(); + * Queue response = cloudTasksClient.getQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -261,6 +374,19 @@ public final Queue getQueue(GetQueueRequest request) { * Gets a queue. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetQueueRequest request = + * GetQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setReadMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * Queue queue = Queue.newBuilder().build(); + * Queue response = cloudTasksClient.createQueue(parent, queue); + * } + * }+ * * @param parent Required. The location name in which the queue will be created. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` *
The list of allowed locations can be obtained by calling Cloud Tasks' implementation of @@ -306,6 +442,16 @@ public final Queue createQueue(LocationName parent, Queue queue) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue queue = Queue.newBuilder().build(); + * Queue response = cloudTasksClient.createQueue(parent, queue); + * } + * }+ * * @param parent Required. The location name in which the queue will be created. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` *
The list of allowed locations can be obtained by calling Cloud Tasks' implementation of @@ -332,6 +478,19 @@ public final Queue createQueue(String parent, Queue queue) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateQueueRequest request = + * CreateQueueRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setQueue(Queue.newBuilder().build()) + * .build(); + * Queue response = cloudTasksClient.createQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -351,6 +510,19 @@ public final Queue createQueue(CreateQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateQueueRequest request = + * CreateQueueRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setQueue(Queue.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.createQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * Queue queue = Queue.newBuilder().build(); + * FieldMask updateMask = FieldMask.newBuilder().build(); + * Queue response = cloudTasksClient.updateQueue(queue, updateMask); + * } + * }+ * * @param queue Required. The queue to create or update. *
The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be specified. *
Output only fields cannot be modified using UpdateQueue. Any value specified for an @@ -397,6 +579,19 @@ public final Queue updateQueue(Queue queue, FieldMask updateMask) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * UpdateQueueRequest request = + * UpdateQueueRequest.newBuilder() + * .setQueue(Queue.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * Queue response = cloudTasksClient.updateQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -418,6 +613,19 @@ public final Queue updateQueue(UpdateQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * UpdateQueueRequest request = + * UpdateQueueRequest.newBuilder() + * .setQueue(Queue.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.updateQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * cloudTasksClient.deleteQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -457,6 +674,15 @@ public final void deleteQueue(QueueName name) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * cloudTasksClient.deleteQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -478,6 +704,18 @@ public final void deleteQueue(String name) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteQueueRequest request = + * DeleteQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * cloudTasksClient.deleteQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -498,6 +736,18 @@ public final void deleteQueue(DeleteQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteQueueRequest request = + * DeleteQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.deleteQueueCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.purgeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -531,6 +790,15 @@ public final Queue purgeQueue(QueueName name) { *
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.purgeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -549,6 +817,18 @@ public final Queue purgeQueue(String name) { *
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PurgeQueueRequest request = + * PurgeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.purgeQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -566,6 +846,18 @@ public final Queue purgeQueue(PurgeQueueRequest request) { * the purge takes effect. A purge is irreversible. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PurgeQueueRequest request = + * PurgeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.purgeQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.pauseQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -601,6 +902,15 @@ public final Queue pauseQueue(QueueName name) { * [state][google.cloud.tasks.v2beta2.Queue.state] is * [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.pauseQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -620,6 +930,18 @@ public final Queue pauseQueue(String name) { * [state][google.cloud.tasks.v2beta2.Queue.state] is * [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PauseQueueRequest request = + * PauseQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.pauseQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -638,6 +960,18 @@ public final Queue pauseQueue(PauseQueueRequest request) { * [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED]. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PauseQueueRequest request = + * PauseQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.pauseQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.resumeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -681,6 +1024,15 @@ public final Queue resumeQueue(QueueName name) { * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.resumeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -704,6 +1056,18 @@ public final Queue resumeQueue(String name) { * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResumeQueueRequest request = + * ResumeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.resumeQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -726,6 +1090,18 @@ public final Queue resumeQueue(ResumeQueueRequest request) { * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResumeQueueRequest request = + * ResumeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.resumeQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * Policy response = cloudTasksClient.getIamPolicy(resource); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -767,6 +1152,15 @@ public final Policy getIamPolicy(ResourceName resource) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * Policy response = cloudTasksClient.getIamPolicy(resource); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -788,6 +1182,19 @@ public final Policy getIamPolicy(String resource) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetIamPolicyRequest request = + * GetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setOptions(GetPolicyOptions.newBuilder().build()) + * .build(); + * Policy response = cloudTasksClient.getIamPolicy(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -812,6 +1219,19 @@ public final Policy getIamPolicy(QueueName queueName) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetIamPolicyRequest request = + * GetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setOptions(GetPolicyOptions.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * Policy policy = Policy.newBuilder().build(); + * Policy response = cloudTasksClient.setIamPolicy(resource, policy); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -863,6 +1293,16 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * Policy policy = Policy.newBuilder().build(); + * Policy response = cloudTasksClient.setIamPolicy(resource, policy); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -891,6 +1331,19 @@ public final Policy setIamPolicy(String resource, Policy policy) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * SetIamPolicyRequest request = + * SetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .build(); + * Policy response = cloudTasksClient.setIamPolicy(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -918,6 +1371,19 @@ public final Policy setIamPolicy(QueueName queue, Policy policy) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * SetIamPolicyRequest request = + * SetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.setIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * List+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -960,6 +1437,17 @@ public final TestIamPermissionsResponse testIamPermissions( * command-line tools, not for authorization checking. This operation may "fail open" without * warning. * + *permissions = new ArrayList<>(); + * TestIamPermissionsResponse response = + * cloudTasksClient.testIamPermissions(resource, permissions); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * List+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -987,6 +1475,19 @@ public final TestIamPermissionsResponse testIamPermissions( * command-line tools, not for authorization checking. This operation may "fail open" without * warning. * + *permissions = new ArrayList<>(); + * TestIamPermissionsResponse response = + * cloudTasksClient.testIamPermissions(resource, permissions); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TestIamPermissionsRequest request = + * TestIamPermissionsRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .addAllPermissions(new ArrayList+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1010,6 +1511,20 @@ public final TestIamPermissionsResponse testIamPermissions( * warning. * *()) + * .build(); + * TestIamPermissionsResponse response = cloudTasksClient.testIamPermissions(request); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TestIamPermissionsRequest request = + * TestIamPermissionsRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .addAllPermissions(new ArrayList*/ public final UnaryCallable()) + * .build(); + * ApiFuture future = + * cloudTasksClient.testIamPermissionsCallable().futureCall(request); + * // Do something. + * TestIamPermissionsResponse response = future.get(); + * } + * }
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * for (Task element : cloudTasksClient.listTasks(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1048,6 +1574,17 @@ public final ListTasksPagedResponse listTasks(QueueName parent) { * *
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * for (Task element : cloudTasksClient.listTasks(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1068,6 +1605,22 @@ public final ListTasksPagedResponse listTasks(String parent) { * *
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Task element : cloudTasksClient.listTasks(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1087,6 +1640,22 @@ public final ListTasksPagedResponse listTasks(ListTasksRequest request) { *
The tasks may be returned in any order. The ordering may change at any time. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.listTasksPagedCallable().futureCall(request); + * // Do something. + * for (Task element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
The tasks may be returned in any order. The ordering may change at any time. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * while (true) { + * ListTasksResponse response = cloudTasksClient.listTasksCallable().call(request); + * for (Task element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }*/ public final UnaryCallable
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Task response = cloudTasksClient.getTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1127,6 +1722,15 @@ public final Task getTask(TaskName name) { /** * Gets a task. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task response = cloudTasksClient.getTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1140,6 +1744,18 @@ public final Task getTask(String name) { /** * Gets a task. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetTaskRequest request = + * GetTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * Task response = cloudTasksClient.getTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1152,6 +1768,18 @@ public final Task getTask(GetTaskRequest request) { * Gets a task. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetTaskRequest request = + * GetTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Task task = Task.newBuilder().build(); + * Task response = cloudTasksClient.createTask(parent, task); + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` *
The queue must already exist. @@ -1218,6 +1856,16 @@ public final Task createTask(QueueName parent, Task task) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task task = Task.newBuilder().build(); + * Task response = cloudTasksClient.createTask(parent, task); + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` *
The queue must already exist. @@ -1264,6 +1912,19 @@ public final Task createTask(String parent, Task task) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateTaskRequest request = + * CreateTaskRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setTask(Task.newBuilder().build()) + * .build(); + * Task response = cloudTasksClient.createTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1284,6 +1945,19 @@ public final Task createTask(CreateTaskRequest request) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateTaskRequest request = + * CreateTaskRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setTask(Task.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.createTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * cloudTasksClient.deleteTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1313,6 +1996,15 @@ public final void deleteTask(TaskName name) { *
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * cloudTasksClient.deleteTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1329,6 +2021,18 @@ public final void deleteTask(String name) { *
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteTaskRequest request = + * DeleteTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * cloudTasksClient.deleteTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1344,6 +2048,18 @@ public final void deleteTask(DeleteTaskRequest request) { * completed successfully or permanently failed. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteTaskRequest request = + * DeleteTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.deleteTaskCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Duration leaseDuration = Duration.newBuilder().build(); + * LeaseTasksResponse response = cloudTasksClient.leaseTasks(parent, leaseDuration); + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @param leaseDuration Required. The duration of the lease. @@ -1421,6 +2147,16 @@ public final LeaseTasksResponse leaseTasks(QueueName parent, Duration leaseDurat * [max_tasks_dispatched_per_second][google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second] * is exceeded. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Duration leaseDuration = Duration.newBuilder().build(); + * LeaseTasksResponse response = cloudTasksClient.leaseTasks(parent, leaseDuration); + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @param leaseDuration Required. The duration of the lease. @@ -1468,6 +2204,21 @@ public final LeaseTasksResponse leaseTasks(String parent, Duration leaseDuration * [max_tasks_dispatched_per_second][google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second] * is exceeded. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * LeaseTasksRequest request = + * LeaseTasksRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setMaxTasks(-233969421) + * .setLeaseDuration(Duration.newBuilder().build()) + * .setFilter("filter-1274492040") + * .build(); + * LeaseTasksResponse response = cloudTasksClient.leaseTasks(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1498,6 +2249,22 @@ public final LeaseTasksResponse leaseTasks(LeaseTasksRequest request) { * is exceeded. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * LeaseTasksRequest request = + * LeaseTasksRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setMaxTasks(-233969421) + * .setLeaseDuration(Duration.newBuilder().build()) + * .setFilter("filter-1274492040") + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = + * cloudTasksClient.leaseTasksCallable().futureCall(request); + * // Do something. + * LeaseTasksResponse response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Timestamp scheduleTime = Timestamp.newBuilder().build(); + * cloudTasksClient.acknowledgeTask(name, scheduleTime); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @param scheduleTime Required. The task's current schedule time, available in the @@ -1553,6 +2330,16 @@ public final void acknowledgeTask(TaskName name, Timestamp scheduleTime) { * [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask], or * [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Timestamp scheduleTime = Timestamp.newBuilder().build(); + * cloudTasksClient.acknowledgeTask(name, scheduleTime); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @param scheduleTime Required. The task's current schedule time, available in the @@ -1584,6 +2371,19 @@ public final void acknowledgeTask(String name, Timestamp scheduleTime) { * [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask], or * [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * AcknowledgeTaskRequest request = + * AcknowledgeTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setScheduleTime(Timestamp.newBuilder().build()) + * .build(); + * cloudTasksClient.acknowledgeTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1608,6 +2408,19 @@ public final void acknowledgeTask(AcknowledgeTaskRequest request) { * [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * AcknowledgeTaskRequest request = + * AcknowledgeTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setScheduleTime(Timestamp.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.acknowledgeTaskCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Timestamp scheduleTime = Timestamp.newBuilder().build(); + * Duration leaseDuration = Duration.newBuilder().build(); + * Task response = cloudTasksClient.renewLease(name, scheduleTime, leaseDuration); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @param scheduleTime Required. The task's current schedule time, available in the @@ -1651,6 +2475,17 @@ public final Task renewLease(TaskName name, Timestamp scheduleTime, Duration lea * new task lease will be returned in the task's * [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Timestamp scheduleTime = Timestamp.newBuilder().build(); + * Duration leaseDuration = Duration.newBuilder().build(); + * Task response = cloudTasksClient.renewLease(name, scheduleTime, leaseDuration); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @param scheduleTime Required. The task's current schedule time, available in the @@ -1681,6 +2516,20 @@ public final Task renewLease(String name, Timestamp scheduleTime, Duration lease * new task lease will be returned in the task's * [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * RenewLeaseRequest request = + * RenewLeaseRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setScheduleTime(Timestamp.newBuilder().build()) + * .setLeaseDuration(Duration.newBuilder().build()) + * .build(); + * Task response = cloudTasksClient.renewLease(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1697,6 +2546,20 @@ public final Task renewLease(RenewLeaseRequest request) { * [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * RenewLeaseRequest request = + * RenewLeaseRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setScheduleTime(Timestamp.newBuilder().build()) + * .setLeaseDuration(Duration.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.renewLeaseCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Timestamp scheduleTime = Timestamp.newBuilder().build(); + * Task response = cloudTasksClient.cancelLease(name, scheduleTime); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @param scheduleTime Required. The task's current schedule time, available in the @@ -1738,6 +2611,16 @@ public final Task cancelLease(TaskName name, Timestamp scheduleTime) { * available to be leased to the next caller of * [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Timestamp scheduleTime = Timestamp.newBuilder().build(); + * Task response = cloudTasksClient.cancelLease(name, scheduleTime); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @param scheduleTime Required. The task's current schedule time, available in the @@ -1762,6 +2645,19 @@ public final Task cancelLease(String name, Timestamp scheduleTime) { * available to be leased to the next caller of * [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CancelLeaseRequest request = + * CancelLeaseRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setScheduleTime(Timestamp.newBuilder().build()) + * .build(); + * Task response = cloudTasksClient.cancelLease(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1779,6 +2675,19 @@ public final Task cancelLease(CancelLeaseRequest request) { * [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CancelLeaseRequest request = + * CancelLeaseRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setScheduleTime(Timestamp.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.cancelLeaseCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
[RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] cannot be called on a [pull * task][google.cloud.tasks.v2beta2.PullMessage]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Task response = cloudTasksClient.runTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1852,6 +2770,15 @@ public final Task runTask(TaskName name) { *
[RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] cannot be called on a [pull * task][google.cloud.tasks.v2beta2.PullMessage]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task response = cloudTasksClient.runTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1890,6 +2817,18 @@ public final Task runTask(String name) { *
[RunTask][google.cloud.tasks.v2beta2.CloudTasks.RunTask] cannot be called on a [pull * task][google.cloud.tasks.v2beta2.PullMessage]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * RunTaskRequest request = + * RunTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * Task response = cloudTasksClient.runTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1927,6 +2866,18 @@ public final Task runTask(RunTaskRequest request) { * task][google.cloud.tasks.v2beta2.PullMessage]. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * RunTaskRequest request = + * RunTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.runTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
Sample for CloudTasksClient: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }*/ @Generated("by gapic-generator-java") package com.google.cloud.tasks.v2beta2; diff --git a/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta3/CloudTasksClient.java b/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta3/CloudTasksClient.java index 24b8ff73..a0036fb5 100644 --- a/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta3/CloudTasksClient.java +++ b/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta3/CloudTasksClient.java @@ -50,6 +50,13 @@ *
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: * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = 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(). * @@ -154,6 +161,17 @@ public CloudTasksStub getStub() { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * for (Queue element : cloudTasksClient.listQueues(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -170,6 +188,17 @@ public final ListQueuesPagedResponse listQueues(LocationName parent) { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * for (Queue element : cloudTasksClient.listQueues(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -185,6 +214,24 @@ public final ListQueuesPagedResponse listQueues(String parent) { * *
Queues are returned in lexicographical order. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListQueuesRequest request = + * ListQueuesRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setReadMask(FieldMask.newBuilder().build()) + * .build(); + * for (Queue element : cloudTasksClient.listQueues(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -199,6 +246,24 @@ public final ListQueuesPagedResponse listQueues(ListQueuesRequest request) { *
Queues are returned in lexicographical order. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListQueuesRequest request = + * ListQueuesRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setReadMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.listQueuesPagedCallable().futureCall(request); + * // Do something. + * for (Queue element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Queues are returned in lexicographical order. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * while (true) { + * ListQueuesResponse response = cloudTasksClient.listQueuesCallable().call(request); + * for (Queue element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }*/ public final UnaryCallable
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }+ * * @param name Required. The resource name of the queue. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -234,6 +325,15 @@ public final Queue getQueue(QueueName name) { /** * Gets a queue. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }+ * * @param name Required. The resource name of the queue. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -247,6 +347,19 @@ public final Queue getQueue(String name) { /** * Gets a queue. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetQueueRequest request = + * GetQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setReadMask(FieldMask.newBuilder().build()) + * .build(); + * Queue response = cloudTasksClient.getQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -259,6 +372,19 @@ public final Queue getQueue(GetQueueRequest request) { * Gets a queue. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetQueueRequest request = + * GetQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setReadMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * Queue queue = Queue.newBuilder().build(); + * Queue response = cloudTasksClient.createQueue(parent, queue); + * } + * }+ * * @param parent Required. The location name in which the queue will be created. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` *
The list of allowed locations can be obtained by calling Cloud Tasks' implementation of @@ -304,6 +440,16 @@ public final Queue createQueue(LocationName parent, Queue queue) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue queue = Queue.newBuilder().build(); + * Queue response = cloudTasksClient.createQueue(parent, queue); + * } + * }+ * * @param parent Required. The location name in which the queue will be created. For example: * `projects/PROJECT_ID/locations/LOCATION_ID` *
The list of allowed locations can be obtained by calling Cloud Tasks' implementation of @@ -330,6 +476,19 @@ public final Queue createQueue(String parent, Queue queue) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateQueueRequest request = + * CreateQueueRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setQueue(Queue.newBuilder().build()) + * .build(); + * Queue response = cloudTasksClient.createQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -349,6 +508,19 @@ public final Queue createQueue(CreateQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateQueueRequest request = + * CreateQueueRequest.newBuilder() + * .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .setQueue(Queue.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.createQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * Queue queue = Queue.newBuilder().build(); + * FieldMask updateMask = FieldMask.newBuilder().build(); + * Queue response = cloudTasksClient.updateQueue(queue, updateMask); + * } + * }+ * * @param queue Required. The queue to create or update. *
The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be specified. *
Output only fields cannot be modified using UpdateQueue. Any value specified for an @@ -395,6 +577,19 @@ public final Queue updateQueue(Queue queue, FieldMask updateMask) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * UpdateQueueRequest request = + * UpdateQueueRequest.newBuilder() + * .setQueue(Queue.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * Queue response = cloudTasksClient.updateQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -416,6 +611,19 @@ public final Queue updateQueue(UpdateQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * UpdateQueueRequest request = + * UpdateQueueRequest.newBuilder() + * .setQueue(Queue.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.updateQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * cloudTasksClient.deleteQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -455,6 +672,15 @@ public final void deleteQueue(QueueName name) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * cloudTasksClient.deleteQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -476,6 +702,18 @@ public final void deleteQueue(String name) { * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteQueueRequest request = + * DeleteQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * cloudTasksClient.deleteQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -496,6 +734,18 @@ public final void deleteQueue(DeleteQueueRequest request) { * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteQueueRequest request = + * DeleteQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.deleteQueueCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.purgeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -529,6 +788,15 @@ public final Queue purgeQueue(QueueName name) { *
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.purgeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -547,6 +815,18 @@ public final Queue purgeQueue(String name) { *
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: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PurgeQueueRequest request = + * PurgeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.purgeQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -564,6 +844,18 @@ public final Queue purgeQueue(PurgeQueueRequest request) { * the purge takes effect. A purge is irreversible. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PurgeQueueRequest request = + * PurgeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.purgeQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.pauseQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -599,6 +900,15 @@ public final Queue pauseQueue(QueueName name) { * [state][google.cloud.tasks.v2beta3.Queue.state] is * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.pauseQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -618,6 +928,18 @@ public final Queue pauseQueue(String name) { * [state][google.cloud.tasks.v2beta3.Queue.state] is * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED]. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PauseQueueRequest request = + * PauseQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.pauseQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -636,6 +958,18 @@ public final Queue pauseQueue(PauseQueueRequest request) { * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED]. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * PauseQueueRequest request = + * PauseQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.pauseQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.resumeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -679,6 +1022,15 @@ public final Queue resumeQueue(QueueName name) { * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString(); + * Queue response = cloudTasksClient.resumeQueue(name); + * } + * }+ * * @param name Required. The queue name. For example: * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -702,6 +1054,18 @@ public final Queue resumeQueue(String name) { * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResumeQueueRequest request = + * ResumeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * Queue response = cloudTasksClient.resumeQueue(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -724,6 +1088,18 @@ public final Queue resumeQueue(ResumeQueueRequest request) { * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResumeQueueRequest request = + * ResumeQueueRequest.newBuilder() + * .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.resumeQueueCallable().futureCall(request); + * // Do something. + * Queue response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * Policy response = cloudTasksClient.getIamPolicy(resource); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -765,6 +1150,15 @@ public final Policy getIamPolicy(ResourceName resource) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * Policy response = cloudTasksClient.getIamPolicy(resource); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -786,6 +1180,19 @@ public final Policy getIamPolicy(String resource) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetIamPolicyRequest request = + * GetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setOptions(GetPolicyOptions.newBuilder().build()) + * .build(); + * Policy response = cloudTasksClient.getIamPolicy(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -810,6 +1217,19 @@ public final Policy getIamPolicy(QueueName queueName) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetIamPolicyRequest request = + * GetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setOptions(GetPolicyOptions.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * Policy policy = Policy.newBuilder().build(); + * Policy response = cloudTasksClient.setIamPolicy(resource, policy); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -861,6 +1291,16 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * Policy policy = Policy.newBuilder().build(); + * Policy response = cloudTasksClient.setIamPolicy(resource, policy); + * } + * }+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -889,6 +1329,19 @@ public final Policy setIamPolicy(String resource, Policy policy) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * SetIamPolicyRequest request = + * SetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .build(); + * Policy response = cloudTasksClient.setIamPolicy(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -916,6 +1369,19 @@ public final Policy setIamPolicy(QueueName queue, Policy policy) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * SetIamPolicyRequest request = + * SetIamPolicyRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.setIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ResourceName resource = LocationName.of("[PROJECT]", "[LOCATION]"); + * List+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -958,6 +1435,17 @@ public final TestIamPermissionsResponse testIamPermissions( * command-line tools, not for authorization checking. This operation may "fail open" without * warning. * + *permissions = new ArrayList<>(); + * TestIamPermissionsResponse response = + * cloudTasksClient.testIamPermissions(resource, permissions); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String resource = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * List+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -985,6 +1473,19 @@ public final TestIamPermissionsResponse testIamPermissions( * command-line tools, not for authorization checking. This operation may "fail open" without * warning. * + *permissions = new ArrayList<>(); + * TestIamPermissionsResponse response = + * cloudTasksClient.testIamPermissions(resource, permissions); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TestIamPermissionsRequest request = + * TestIamPermissionsRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .addAllPermissions(new ArrayList+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1008,6 +1509,20 @@ public final TestIamPermissionsResponse testIamPermissions( * warning. * *()) + * .build(); + * TestIamPermissionsResponse response = cloudTasksClient.testIamPermissions(request); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TestIamPermissionsRequest request = + * TestIamPermissionsRequest.newBuilder() + * .setResource(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .addAllPermissions(new ArrayList*/ public final UnaryCallable()) + * .build(); + * ApiFuture future = + * cloudTasksClient.testIamPermissionsCallable().futureCall(request); + * // Do something. + * TestIamPermissionsResponse response = future.get(); + * } + * }
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * for (Task element : cloudTasksClient.listTasks(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1046,6 +1572,17 @@ public final ListTasksPagedResponse listTasks(QueueName parent) { * *
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * for (Task element : cloudTasksClient.listTasks(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1066,6 +1603,22 @@ public final ListTasksPagedResponse listTasks(String parent) { * *
The tasks may be returned in any order. The ordering may change at any time. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Task element : cloudTasksClient.listTasks(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1085,6 +1638,22 @@ public final ListTasksPagedResponse listTasks(ListTasksRequest request) { *
The tasks may be returned in any order. The ordering may change at any time. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.listTasksPagedCallable().futureCall(request); + * // Do something. + * for (Task element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
The tasks may be returned in any order. The ordering may change at any time. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * while (true) { + * ListTasksResponse response = cloudTasksClient.listTasksCallable().call(request); + * for (Task element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }*/ public final UnaryCallable
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Task response = cloudTasksClient.getTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1125,6 +1720,15 @@ public final Task getTask(TaskName name) { /** * Gets a task. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task response = cloudTasksClient.getTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1138,6 +1742,18 @@ public final Task getTask(String name) { /** * Gets a task. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetTaskRequest request = + * GetTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * Task response = cloudTasksClient.getTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1150,6 +1766,18 @@ public final Task getTask(GetTaskRequest request) { * Gets a task. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * GetTaskRequest request = + * GetTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.getTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Task task = Task.newBuilder().build(); + * Task response = cloudTasksClient.createTask(parent, task); + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` *
The queue must already exist. @@ -1212,6 +1850,16 @@ public final Task createTask(QueueName parent, Task task) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String parent = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task task = Task.newBuilder().build(); + * Task response = cloudTasksClient.createTask(parent, task); + * } + * }+ * * @param parent Required. The queue name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` *
The queue must already exist. @@ -1256,6 +1904,19 @@ public final Task createTask(String parent, Task task) { *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateTaskRequest request = + * CreateTaskRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setTask(Task.newBuilder().build()) + * .build(); + * Task response = cloudTasksClient.createTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1274,6 +1935,19 @@ public final Task createTask(CreateTaskRequest request) { * * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * CreateTaskRequest request = + * CreateTaskRequest.newBuilder() + * .setParent(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .setTask(Task.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.createTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has * executed successfully or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * cloudTasksClient.deleteTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1303,6 +1986,15 @@ public final void deleteTask(TaskName name) { *
A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has * executed successfully or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * cloudTasksClient.deleteTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1319,6 +2011,18 @@ public final void deleteTask(String name) { *
A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has * executed successfully or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteTaskRequest request = + * DeleteTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * cloudTasksClient.deleteTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1334,6 +2038,18 @@ public final void deleteTask(DeleteTaskRequest request) { * executed successfully or permanently failed. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * DeleteTaskRequest request = + * DeleteTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.deleteTaskCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]"); + * Task response = cloudTasksClient.runTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1401,6 +2126,15 @@ public final Task runTask(TaskName name) { * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded * or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString(); + * Task response = cloudTasksClient.runTask(name); + * } + * }+ * * @param name Required. The task name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1436,6 +2170,18 @@ public final Task runTask(String name) { * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded * or permanently failed. * + *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * RunTaskRequest request = + * RunTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * Task response = cloudTasksClient.runTask(request); + * } + * }+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1470,6 +2216,18 @@ public final Task runTask(RunTaskRequest request) { * or permanently failed. * *
Sample code: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * RunTaskRequest request = + * RunTaskRequest.newBuilder() + * .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = cloudTasksClient.runTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
Sample for CloudTasksClient: + * + *
{@code + * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) { + * QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]"); + * Queue response = cloudTasksClient.getQueue(name); + * } + * }*/ @Generated("by gapic-generator-java") package com.google.cloud.tasks.v2beta3; diff --git a/synth.metadata b/synth.metadata index 2e561a1f..78971199 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "a0b91c3dfa479290ed8921fea27020ac4c492763", - "internalRef": "353032056" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {