• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.tasks.v2beta3;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.core.BetaApi;
22 import com.google.api.gax.core.BackgroundResource;
23 import com.google.api.gax.paging.AbstractFixedSizeCollection;
24 import com.google.api.gax.paging.AbstractPage;
25 import com.google.api.gax.paging.AbstractPagedListResponse;
26 import com.google.api.gax.rpc.PageContext;
27 import com.google.api.gax.rpc.UnaryCallable;
28 import com.google.api.resourcenames.ResourceName;
29 import com.google.cloud.tasks.v2beta3.stub.CloudTasksStub;
30 import com.google.cloud.tasks.v2beta3.stub.CloudTasksStubSettings;
31 import com.google.common.util.concurrent.MoreExecutors;
32 import com.google.iam.v1.GetIamPolicyRequest;
33 import com.google.iam.v1.Policy;
34 import com.google.iam.v1.SetIamPolicyRequest;
35 import com.google.iam.v1.TestIamPermissionsRequest;
36 import com.google.iam.v1.TestIamPermissionsResponse;
37 import com.google.protobuf.Empty;
38 import com.google.protobuf.FieldMask;
39 import java.io.IOException;
40 import java.util.List;
41 import java.util.concurrent.TimeUnit;
42 import javax.annotation.Generated;
43 
44 // AUTO-GENERATED DOCUMENTATION AND CLASS.
45 /**
46  * Service Description: Cloud Tasks allows developers to manage the execution of background work in
47  * their applications.
48  *
49  * <p>This class provides the ability to make remote calls to the backing service through method
50  * calls that map to API methods. Sample code to get started:
51  *
52  * <pre>{@code
53  * // This snippet has been automatically generated and should be regarded as a code template only.
54  * // It will require modifications to work:
55  * // - It may require correct/in-range values for request initialization.
56  * // - It may require specifying regional endpoints when creating the service client as shown in
57  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
58  * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
59  *   QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
60  *   Queue response = cloudTasksClient.getQueue(name);
61  * }
62  * }</pre>
63  *
64  * <p>Note: close() needs to be called on the CloudTasksClient object to clean up resources such as
65  * threads. In the example above, try-with-resources is used, which automatically calls close().
66  *
67  * <p>The surface of this class includes several types of Java methods for each of the API's
68  * methods:
69  *
70  * <ol>
71  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
72  *       converted into function parameters. It may be the case that not all fields are available as
73  *       parameters, and not every API method will have a flattened method entry point.
74  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
75  *       which must be constructed before the call. Not every API method will have a request object
76  *       method.
77  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
78  *       callable object, which can be used to initiate calls to the service.
79  * </ol>
80  *
81  * <p>See the individual methods for example code.
82  *
83  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
84  * these names, this class includes a format method for each type of name, and additionally a parse
85  * method to extract the individual identifiers contained within names that are returned.
86  *
87  * <p>This class can be customized by passing in a custom instance of CloudTasksSettings to
88  * create(). For example:
89  *
90  * <p>To customize credentials:
91  *
92  * <pre>{@code
93  * // This snippet has been automatically generated and should be regarded as a code template only.
94  * // It will require modifications to work:
95  * // - It may require correct/in-range values for request initialization.
96  * // - It may require specifying regional endpoints when creating the service client as shown in
97  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
98  * CloudTasksSettings cloudTasksSettings =
99  *     CloudTasksSettings.newBuilder()
100  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
101  *         .build();
102  * CloudTasksClient cloudTasksClient = CloudTasksClient.create(cloudTasksSettings);
103  * }</pre>
104  *
105  * <p>To customize the endpoint:
106  *
107  * <pre>{@code
108  * // This snippet has been automatically generated and should be regarded as a code template only.
109  * // It will require modifications to work:
110  * // - It may require correct/in-range values for request initialization.
111  * // - It may require specifying regional endpoints when creating the service client as shown in
112  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
113  * CloudTasksSettings cloudTasksSettings =
114  *     CloudTasksSettings.newBuilder().setEndpoint(myEndpoint).build();
115  * CloudTasksClient cloudTasksClient = CloudTasksClient.create(cloudTasksSettings);
116  * }</pre>
117  *
118  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
119  * the wire:
120  *
121  * <pre>{@code
122  * // This snippet has been automatically generated and should be regarded as a code template only.
123  * // It will require modifications to work:
124  * // - It may require correct/in-range values for request initialization.
125  * // - It may require specifying regional endpoints when creating the service client as shown in
126  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
127  * CloudTasksSettings cloudTasksSettings = CloudTasksSettings.newHttpJsonBuilder().build();
128  * CloudTasksClient cloudTasksClient = CloudTasksClient.create(cloudTasksSettings);
129  * }</pre>
130  *
131  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
132  */
133 @BetaApi
134 @Generated("by gapic-generator-java")
135 public class CloudTasksClient implements BackgroundResource {
136   private final CloudTasksSettings settings;
137   private final CloudTasksStub stub;
138 
139   /** Constructs an instance of CloudTasksClient with default settings. */
create()140   public static final CloudTasksClient create() throws IOException {
141     return create(CloudTasksSettings.newBuilder().build());
142   }
143 
144   /**
145    * Constructs an instance of CloudTasksClient, using the given settings. The channels are created
146    * based on the settings passed in, or defaults for any settings that are not set.
147    */
create(CloudTasksSettings settings)148   public static final CloudTasksClient create(CloudTasksSettings settings) throws IOException {
149     return new CloudTasksClient(settings);
150   }
151 
152   /**
153    * Constructs an instance of CloudTasksClient, using the given stub for making calls. This is for
154    * advanced usage - prefer using create(CloudTasksSettings).
155    */
create(CloudTasksStub stub)156   public static final CloudTasksClient create(CloudTasksStub stub) {
157     return new CloudTasksClient(stub);
158   }
159 
160   /**
161    * Constructs an instance of CloudTasksClient, using the given settings. This is protected so that
162    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
163    */
CloudTasksClient(CloudTasksSettings settings)164   protected CloudTasksClient(CloudTasksSettings settings) throws IOException {
165     this.settings = settings;
166     this.stub = ((CloudTasksStubSettings) settings.getStubSettings()).createStub();
167   }
168 
CloudTasksClient(CloudTasksStub stub)169   protected CloudTasksClient(CloudTasksStub stub) {
170     this.settings = null;
171     this.stub = stub;
172   }
173 
getSettings()174   public final CloudTasksSettings getSettings() {
175     return settings;
176   }
177 
getStub()178   public CloudTasksStub getStub() {
179     return stub;
180   }
181 
182   // AUTO-GENERATED DOCUMENTATION AND METHOD.
183   /**
184    * Lists queues.
185    *
186    * <p>Queues are returned in lexicographical order.
187    *
188    * <p>Sample code:
189    *
190    * <pre>{@code
191    * // This snippet has been automatically generated and should be regarded as a code template only.
192    * // It will require modifications to work:
193    * // - It may require correct/in-range values for request initialization.
194    * // - It may require specifying regional endpoints when creating the service client as shown in
195    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
196    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
197    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
198    *   for (Queue element : cloudTasksClient.listQueues(parent).iterateAll()) {
199    *     // doThingsWith(element);
200    *   }
201    * }
202    * }</pre>
203    *
204    * @param parent Required. The location name. For example:
205    *     `projects/PROJECT_ID/locations/LOCATION_ID`
206    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
207    */
listQueues(LocationName parent)208   public final ListQueuesPagedResponse listQueues(LocationName parent) {
209     ListQueuesRequest request =
210         ListQueuesRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build();
211     return listQueues(request);
212   }
213 
214   // AUTO-GENERATED DOCUMENTATION AND METHOD.
215   /**
216    * Lists queues.
217    *
218    * <p>Queues are returned in lexicographical order.
219    *
220    * <p>Sample code:
221    *
222    * <pre>{@code
223    * // This snippet has been automatically generated and should be regarded as a code template only.
224    * // It will require modifications to work:
225    * // - It may require correct/in-range values for request initialization.
226    * // - It may require specifying regional endpoints when creating the service client as shown in
227    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
228    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
229    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
230    *   for (Queue element : cloudTasksClient.listQueues(parent).iterateAll()) {
231    *     // doThingsWith(element);
232    *   }
233    * }
234    * }</pre>
235    *
236    * @param parent Required. The location name. For example:
237    *     `projects/PROJECT_ID/locations/LOCATION_ID`
238    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
239    */
listQueues(String parent)240   public final ListQueuesPagedResponse listQueues(String parent) {
241     ListQueuesRequest request = ListQueuesRequest.newBuilder().setParent(parent).build();
242     return listQueues(request);
243   }
244 
245   // AUTO-GENERATED DOCUMENTATION AND METHOD.
246   /**
247    * Lists queues.
248    *
249    * <p>Queues are returned in lexicographical order.
250    *
251    * <p>Sample code:
252    *
253    * <pre>{@code
254    * // This snippet has been automatically generated and should be regarded as a code template only.
255    * // It will require modifications to work:
256    * // - It may require correct/in-range values for request initialization.
257    * // - It may require specifying regional endpoints when creating the service client as shown in
258    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
259    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
260    *   ListQueuesRequest request =
261    *       ListQueuesRequest.newBuilder()
262    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
263    *           .setFilter("filter-1274492040")
264    *           .setPageSize(883849137)
265    *           .setPageToken("pageToken873572522")
266    *           .setReadMask(FieldMask.newBuilder().build())
267    *           .build();
268    *   for (Queue element : cloudTasksClient.listQueues(request).iterateAll()) {
269    *     // doThingsWith(element);
270    *   }
271    * }
272    * }</pre>
273    *
274    * @param request The request object containing all of the parameters for the API call.
275    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
276    */
listQueues(ListQueuesRequest request)277   public final ListQueuesPagedResponse listQueues(ListQueuesRequest request) {
278     return listQueuesPagedCallable().call(request);
279   }
280 
281   // AUTO-GENERATED DOCUMENTATION AND METHOD.
282   /**
283    * Lists queues.
284    *
285    * <p>Queues are returned in lexicographical order.
286    *
287    * <p>Sample code:
288    *
289    * <pre>{@code
290    * // This snippet has been automatically generated and should be regarded as a code template only.
291    * // It will require modifications to work:
292    * // - It may require correct/in-range values for request initialization.
293    * // - It may require specifying regional endpoints when creating the service client as shown in
294    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
295    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
296    *   ListQueuesRequest request =
297    *       ListQueuesRequest.newBuilder()
298    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
299    *           .setFilter("filter-1274492040")
300    *           .setPageSize(883849137)
301    *           .setPageToken("pageToken873572522")
302    *           .setReadMask(FieldMask.newBuilder().build())
303    *           .build();
304    *   ApiFuture<Queue> future = cloudTasksClient.listQueuesPagedCallable().futureCall(request);
305    *   // Do something.
306    *   for (Queue element : future.get().iterateAll()) {
307    *     // doThingsWith(element);
308    *   }
309    * }
310    * }</pre>
311    */
listQueuesPagedCallable()312   public final UnaryCallable<ListQueuesRequest, ListQueuesPagedResponse> listQueuesPagedCallable() {
313     return stub.listQueuesPagedCallable();
314   }
315 
316   // AUTO-GENERATED DOCUMENTATION AND METHOD.
317   /**
318    * Lists queues.
319    *
320    * <p>Queues are returned in lexicographical order.
321    *
322    * <p>Sample code:
323    *
324    * <pre>{@code
325    * // This snippet has been automatically generated and should be regarded as a code template only.
326    * // It will require modifications to work:
327    * // - It may require correct/in-range values for request initialization.
328    * // - It may require specifying regional endpoints when creating the service client as shown in
329    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
330    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
331    *   ListQueuesRequest request =
332    *       ListQueuesRequest.newBuilder()
333    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
334    *           .setFilter("filter-1274492040")
335    *           .setPageSize(883849137)
336    *           .setPageToken("pageToken873572522")
337    *           .setReadMask(FieldMask.newBuilder().build())
338    *           .build();
339    *   while (true) {
340    *     ListQueuesResponse response = cloudTasksClient.listQueuesCallable().call(request);
341    *     for (Queue element : response.getQueuesList()) {
342    *       // doThingsWith(element);
343    *     }
344    *     String nextPageToken = response.getNextPageToken();
345    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
346    *       request = request.toBuilder().setPageToken(nextPageToken).build();
347    *     } else {
348    *       break;
349    *     }
350    *   }
351    * }
352    * }</pre>
353    */
listQueuesCallable()354   public final UnaryCallable<ListQueuesRequest, ListQueuesResponse> listQueuesCallable() {
355     return stub.listQueuesCallable();
356   }
357 
358   // AUTO-GENERATED DOCUMENTATION AND METHOD.
359   /**
360    * Gets a queue.
361    *
362    * <p>Sample code:
363    *
364    * <pre>{@code
365    * // This snippet has been automatically generated and should be regarded as a code template only.
366    * // It will require modifications to work:
367    * // - It may require correct/in-range values for request initialization.
368    * // - It may require specifying regional endpoints when creating the service client as shown in
369    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
370    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
371    *   QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
372    *   Queue response = cloudTasksClient.getQueue(name);
373    * }
374    * }</pre>
375    *
376    * @param name Required. The resource name of the queue. For example:
377    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
378    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
379    */
getQueue(QueueName name)380   public final Queue getQueue(QueueName name) {
381     GetQueueRequest request =
382         GetQueueRequest.newBuilder().setName(name == null ? null : name.toString()).build();
383     return getQueue(request);
384   }
385 
386   // AUTO-GENERATED DOCUMENTATION AND METHOD.
387   /**
388    * Gets a queue.
389    *
390    * <p>Sample code:
391    *
392    * <pre>{@code
393    * // This snippet has been automatically generated and should be regarded as a code template only.
394    * // It will require modifications to work:
395    * // - It may require correct/in-range values for request initialization.
396    * // - It may require specifying regional endpoints when creating the service client as shown in
397    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
398    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
399    *   String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
400    *   Queue response = cloudTasksClient.getQueue(name);
401    * }
402    * }</pre>
403    *
404    * @param name Required. The resource name of the queue. For example:
405    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
406    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
407    */
getQueue(String name)408   public final Queue getQueue(String name) {
409     GetQueueRequest request = GetQueueRequest.newBuilder().setName(name).build();
410     return getQueue(request);
411   }
412 
413   // AUTO-GENERATED DOCUMENTATION AND METHOD.
414   /**
415    * Gets a queue.
416    *
417    * <p>Sample code:
418    *
419    * <pre>{@code
420    * // This snippet has been automatically generated and should be regarded as a code template only.
421    * // It will require modifications to work:
422    * // - It may require correct/in-range values for request initialization.
423    * // - It may require specifying regional endpoints when creating the service client as shown in
424    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
425    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
426    *   GetQueueRequest request =
427    *       GetQueueRequest.newBuilder()
428    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
429    *           .setReadMask(FieldMask.newBuilder().build())
430    *           .build();
431    *   Queue response = cloudTasksClient.getQueue(request);
432    * }
433    * }</pre>
434    *
435    * @param request The request object containing all of the parameters for the API call.
436    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
437    */
getQueue(GetQueueRequest request)438   public final Queue getQueue(GetQueueRequest request) {
439     return getQueueCallable().call(request);
440   }
441 
442   // AUTO-GENERATED DOCUMENTATION AND METHOD.
443   /**
444    * Gets a queue.
445    *
446    * <p>Sample code:
447    *
448    * <pre>{@code
449    * // This snippet has been automatically generated and should be regarded as a code template only.
450    * // It will require modifications to work:
451    * // - It may require correct/in-range values for request initialization.
452    * // - It may require specifying regional endpoints when creating the service client as shown in
453    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
454    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
455    *   GetQueueRequest request =
456    *       GetQueueRequest.newBuilder()
457    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
458    *           .setReadMask(FieldMask.newBuilder().build())
459    *           .build();
460    *   ApiFuture<Queue> future = cloudTasksClient.getQueueCallable().futureCall(request);
461    *   // Do something.
462    *   Queue response = future.get();
463    * }
464    * }</pre>
465    */
getQueueCallable()466   public final UnaryCallable<GetQueueRequest, Queue> getQueueCallable() {
467     return stub.getQueueCallable();
468   }
469 
470   // AUTO-GENERATED DOCUMENTATION AND METHOD.
471   /**
472    * Creates a queue.
473    *
474    * <p>Queues created with this method allow tasks to live for a maximum of 31 days. After a task
475    * is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
476    *
477    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
478    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
479    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
480    *
481    * <p>Sample code:
482    *
483    * <pre>{@code
484    * // This snippet has been automatically generated and should be regarded as a code template only.
485    * // It will require modifications to work:
486    * // - It may require correct/in-range values for request initialization.
487    * // - It may require specifying regional endpoints when creating the service client as shown in
488    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
489    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
490    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
491    *   Queue queue = Queue.newBuilder().build();
492    *   Queue response = cloudTasksClient.createQueue(parent, queue);
493    * }
494    * }</pre>
495    *
496    * @param parent Required. The location name in which the queue will be created. For example:
497    *     `projects/PROJECT_ID/locations/LOCATION_ID`
498    *     <p>The list of allowed locations can be obtained by calling Cloud Tasks' implementation of
499    *     [ListLocations][google.cloud.location.Locations.ListLocations].
500    * @param queue Required. The queue to create.
501    *     <p>[Queue's name][google.cloud.tasks.v2beta3.Queue.name] cannot be the same as an existing
502    *     queue.
503    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
504    */
createQueue(LocationName parent, Queue queue)505   public final Queue createQueue(LocationName parent, Queue queue) {
506     CreateQueueRequest request =
507         CreateQueueRequest.newBuilder()
508             .setParent(parent == null ? null : parent.toString())
509             .setQueue(queue)
510             .build();
511     return createQueue(request);
512   }
513 
514   // AUTO-GENERATED DOCUMENTATION AND METHOD.
515   /**
516    * Creates a queue.
517    *
518    * <p>Queues created with this method allow tasks to live for a maximum of 31 days. After a task
519    * is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
520    *
521    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
522    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
523    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
524    *
525    * <p>Sample code:
526    *
527    * <pre>{@code
528    * // This snippet has been automatically generated and should be regarded as a code template only.
529    * // It will require modifications to work:
530    * // - It may require correct/in-range values for request initialization.
531    * // - It may require specifying regional endpoints when creating the service client as shown in
532    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
533    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
534    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
535    *   Queue queue = Queue.newBuilder().build();
536    *   Queue response = cloudTasksClient.createQueue(parent, queue);
537    * }
538    * }</pre>
539    *
540    * @param parent Required. The location name in which the queue will be created. For example:
541    *     `projects/PROJECT_ID/locations/LOCATION_ID`
542    *     <p>The list of allowed locations can be obtained by calling Cloud Tasks' implementation of
543    *     [ListLocations][google.cloud.location.Locations.ListLocations].
544    * @param queue Required. The queue to create.
545    *     <p>[Queue's name][google.cloud.tasks.v2beta3.Queue.name] cannot be the same as an existing
546    *     queue.
547    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
548    */
createQueue(String parent, Queue queue)549   public final Queue createQueue(String parent, Queue queue) {
550     CreateQueueRequest request =
551         CreateQueueRequest.newBuilder().setParent(parent).setQueue(queue).build();
552     return createQueue(request);
553   }
554 
555   // AUTO-GENERATED DOCUMENTATION AND METHOD.
556   /**
557    * Creates a queue.
558    *
559    * <p>Queues created with this method allow tasks to live for a maximum of 31 days. After a task
560    * is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
561    *
562    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
563    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
564    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
565    *
566    * <p>Sample code:
567    *
568    * <pre>{@code
569    * // This snippet has been automatically generated and should be regarded as a code template only.
570    * // It will require modifications to work:
571    * // - It may require correct/in-range values for request initialization.
572    * // - It may require specifying regional endpoints when creating the service client as shown in
573    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
574    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
575    *   CreateQueueRequest request =
576    *       CreateQueueRequest.newBuilder()
577    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
578    *           .setQueue(Queue.newBuilder().build())
579    *           .build();
580    *   Queue response = cloudTasksClient.createQueue(request);
581    * }
582    * }</pre>
583    *
584    * @param request The request object containing all of the parameters for the API call.
585    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
586    */
createQueue(CreateQueueRequest request)587   public final Queue createQueue(CreateQueueRequest request) {
588     return createQueueCallable().call(request);
589   }
590 
591   // AUTO-GENERATED DOCUMENTATION AND METHOD.
592   /**
593    * Creates a queue.
594    *
595    * <p>Queues created with this method allow tasks to live for a maximum of 31 days. After a task
596    * is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
597    *
598    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
599    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
600    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
601    *
602    * <p>Sample code:
603    *
604    * <pre>{@code
605    * // This snippet has been automatically generated and should be regarded as a code template only.
606    * // It will require modifications to work:
607    * // - It may require correct/in-range values for request initialization.
608    * // - It may require specifying regional endpoints when creating the service client as shown in
609    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
610    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
611    *   CreateQueueRequest request =
612    *       CreateQueueRequest.newBuilder()
613    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
614    *           .setQueue(Queue.newBuilder().build())
615    *           .build();
616    *   ApiFuture<Queue> future = cloudTasksClient.createQueueCallable().futureCall(request);
617    *   // Do something.
618    *   Queue response = future.get();
619    * }
620    * }</pre>
621    */
createQueueCallable()622   public final UnaryCallable<CreateQueueRequest, Queue> createQueueCallable() {
623     return stub.createQueueCallable();
624   }
625 
626   // AUTO-GENERATED DOCUMENTATION AND METHOD.
627   /**
628    * Updates a queue.
629    *
630    * <p>This method creates the queue if it does not exist and updates the queue if it does exist.
631    *
632    * <p>Queues created with this method allow tasks to live for a maximum of 31 days. After a task
633    * is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
634    *
635    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
636    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
637    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
638    *
639    * <p>Sample code:
640    *
641    * <pre>{@code
642    * // This snippet has been automatically generated and should be regarded as a code template only.
643    * // It will require modifications to work:
644    * // - It may require correct/in-range values for request initialization.
645    * // - It may require specifying regional endpoints when creating the service client as shown in
646    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
647    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
648    *   Queue queue = Queue.newBuilder().build();
649    *   FieldMask updateMask = FieldMask.newBuilder().build();
650    *   Queue response = cloudTasksClient.updateQueue(queue, updateMask);
651    * }
652    * }</pre>
653    *
654    * @param queue Required. The queue to create or update.
655    *     <p>The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be specified.
656    *     <p>Output only fields cannot be modified using UpdateQueue. Any value specified for an
657    *     output only field will be ignored. The queue's
658    *     [name][google.cloud.tasks.v2beta3.Queue.name] cannot be changed.
659    * @param updateMask A mask used to specify which fields of the queue are being updated.
660    *     <p>If empty, then all fields will be updated.
661    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
662    */
updateQueue(Queue queue, FieldMask updateMask)663   public final Queue updateQueue(Queue queue, FieldMask updateMask) {
664     UpdateQueueRequest request =
665         UpdateQueueRequest.newBuilder().setQueue(queue).setUpdateMask(updateMask).build();
666     return updateQueue(request);
667   }
668 
669   // AUTO-GENERATED DOCUMENTATION AND METHOD.
670   /**
671    * Updates a queue.
672    *
673    * <p>This method creates the queue if it does not exist and updates the queue if it does exist.
674    *
675    * <p>Queues created with this method allow tasks to live for a maximum of 31 days. After a task
676    * is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
677    *
678    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
679    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
680    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
681    *
682    * <p>Sample code:
683    *
684    * <pre>{@code
685    * // This snippet has been automatically generated and should be regarded as a code template only.
686    * // It will require modifications to work:
687    * // - It may require correct/in-range values for request initialization.
688    * // - It may require specifying regional endpoints when creating the service client as shown in
689    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
690    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
691    *   UpdateQueueRequest request =
692    *       UpdateQueueRequest.newBuilder()
693    *           .setQueue(Queue.newBuilder().build())
694    *           .setUpdateMask(FieldMask.newBuilder().build())
695    *           .build();
696    *   Queue response = cloudTasksClient.updateQueue(request);
697    * }
698    * }</pre>
699    *
700    * @param request The request object containing all of the parameters for the API call.
701    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
702    */
updateQueue(UpdateQueueRequest request)703   public final Queue updateQueue(UpdateQueueRequest request) {
704     return updateQueueCallable().call(request);
705   }
706 
707   // AUTO-GENERATED DOCUMENTATION AND METHOD.
708   /**
709    * Updates a queue.
710    *
711    * <p>This method creates the queue if it does not exist and updates the queue if it does exist.
712    *
713    * <p>Queues created with this method allow tasks to live for a maximum of 31 days. After a task
714    * is 31 days old, the task will be deleted regardless of whether it was dispatched or not.
715    *
716    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
717    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
718    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
719    *
720    * <p>Sample code:
721    *
722    * <pre>{@code
723    * // This snippet has been automatically generated and should be regarded as a code template only.
724    * // It will require modifications to work:
725    * // - It may require correct/in-range values for request initialization.
726    * // - It may require specifying regional endpoints when creating the service client as shown in
727    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
728    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
729    *   UpdateQueueRequest request =
730    *       UpdateQueueRequest.newBuilder()
731    *           .setQueue(Queue.newBuilder().build())
732    *           .setUpdateMask(FieldMask.newBuilder().build())
733    *           .build();
734    *   ApiFuture<Queue> future = cloudTasksClient.updateQueueCallable().futureCall(request);
735    *   // Do something.
736    *   Queue response = future.get();
737    * }
738    * }</pre>
739    */
updateQueueCallable()740   public final UnaryCallable<UpdateQueueRequest, Queue> updateQueueCallable() {
741     return stub.updateQueueCallable();
742   }
743 
744   // AUTO-GENERATED DOCUMENTATION AND METHOD.
745   /**
746    * Deletes a queue.
747    *
748    * <p>This command will delete the queue even if it has tasks in it.
749    *
750    * <p>Note: If you delete a queue, a queue with the same name can't be created for 7 days.
751    *
752    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
753    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
754    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
755    *
756    * <p>Sample code:
757    *
758    * <pre>{@code
759    * // This snippet has been automatically generated and should be regarded as a code template only.
760    * // It will require modifications to work:
761    * // - It may require correct/in-range values for request initialization.
762    * // - It may require specifying regional endpoints when creating the service client as shown in
763    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
764    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
765    *   QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
766    *   cloudTasksClient.deleteQueue(name);
767    * }
768    * }</pre>
769    *
770    * @param name Required. The queue name. For example:
771    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
772    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
773    */
deleteQueue(QueueName name)774   public final void deleteQueue(QueueName name) {
775     DeleteQueueRequest request =
776         DeleteQueueRequest.newBuilder().setName(name == null ? null : name.toString()).build();
777     deleteQueue(request);
778   }
779 
780   // AUTO-GENERATED DOCUMENTATION AND METHOD.
781   /**
782    * Deletes a queue.
783    *
784    * <p>This command will delete the queue even if it has tasks in it.
785    *
786    * <p>Note: If you delete a queue, a queue with the same name can't be created for 7 days.
787    *
788    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
789    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
790    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
791    *
792    * <p>Sample code:
793    *
794    * <pre>{@code
795    * // This snippet has been automatically generated and should be regarded as a code template only.
796    * // It will require modifications to work:
797    * // - It may require correct/in-range values for request initialization.
798    * // - It may require specifying regional endpoints when creating the service client as shown in
799    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
800    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
801    *   String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
802    *   cloudTasksClient.deleteQueue(name);
803    * }
804    * }</pre>
805    *
806    * @param name Required. The queue name. For example:
807    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
808    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
809    */
deleteQueue(String name)810   public final void deleteQueue(String name) {
811     DeleteQueueRequest request = DeleteQueueRequest.newBuilder().setName(name).build();
812     deleteQueue(request);
813   }
814 
815   // AUTO-GENERATED DOCUMENTATION AND METHOD.
816   /**
817    * Deletes a queue.
818    *
819    * <p>This command will delete the queue even if it has tasks in it.
820    *
821    * <p>Note: If you delete a queue, a queue with the same name can't be created for 7 days.
822    *
823    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
824    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
825    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
826    *
827    * <p>Sample code:
828    *
829    * <pre>{@code
830    * // This snippet has been automatically generated and should be regarded as a code template only.
831    * // It will require modifications to work:
832    * // - It may require correct/in-range values for request initialization.
833    * // - It may require specifying regional endpoints when creating the service client as shown in
834    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
835    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
836    *   DeleteQueueRequest request =
837    *       DeleteQueueRequest.newBuilder()
838    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
839    *           .build();
840    *   cloudTasksClient.deleteQueue(request);
841    * }
842    * }</pre>
843    *
844    * @param request The request object containing all of the parameters for the API call.
845    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
846    */
deleteQueue(DeleteQueueRequest request)847   public final void deleteQueue(DeleteQueueRequest request) {
848     deleteQueueCallable().call(request);
849   }
850 
851   // AUTO-GENERATED DOCUMENTATION AND METHOD.
852   /**
853    * Deletes a queue.
854    *
855    * <p>This command will delete the queue even if it has tasks in it.
856    *
857    * <p>Note: If you delete a queue, a queue with the same name can't be created for 7 days.
858    *
859    * <p>WARNING: Using this method may have unintended side effects if you are using an App Engine
860    * `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and
861    * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
862    *
863    * <p>Sample code:
864    *
865    * <pre>{@code
866    * // This snippet has been automatically generated and should be regarded as a code template only.
867    * // It will require modifications to work:
868    * // - It may require correct/in-range values for request initialization.
869    * // - It may require specifying regional endpoints when creating the service client as shown in
870    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
871    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
872    *   DeleteQueueRequest request =
873    *       DeleteQueueRequest.newBuilder()
874    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
875    *           .build();
876    *   ApiFuture<Empty> future = cloudTasksClient.deleteQueueCallable().futureCall(request);
877    *   // Do something.
878    *   future.get();
879    * }
880    * }</pre>
881    */
deleteQueueCallable()882   public final UnaryCallable<DeleteQueueRequest, Empty> deleteQueueCallable() {
883     return stub.deleteQueueCallable();
884   }
885 
886   // AUTO-GENERATED DOCUMENTATION AND METHOD.
887   /**
888    * Purges a queue by deleting all of its tasks.
889    *
890    * <p>All tasks created before this method is called are permanently deleted.
891    *
892    * <p>Purge operations can take up to one minute to take effect. Tasks might be dispatched before
893    * the purge takes effect. A purge is irreversible.
894    *
895    * <p>Sample code:
896    *
897    * <pre>{@code
898    * // This snippet has been automatically generated and should be regarded as a code template only.
899    * // It will require modifications to work:
900    * // - It may require correct/in-range values for request initialization.
901    * // - It may require specifying regional endpoints when creating the service client as shown in
902    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
903    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
904    *   QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
905    *   Queue response = cloudTasksClient.purgeQueue(name);
906    * }
907    * }</pre>
908    *
909    * @param name Required. The queue name. For example:
910    *     `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
911    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
912    */
purgeQueue(QueueName name)913   public final Queue purgeQueue(QueueName name) {
914     PurgeQueueRequest request =
915         PurgeQueueRequest.newBuilder().setName(name == null ? null : name.toString()).build();
916     return purgeQueue(request);
917   }
918 
919   // AUTO-GENERATED DOCUMENTATION AND METHOD.
920   /**
921    * Purges a queue by deleting all of its tasks.
922    *
923    * <p>All tasks created before this method is called are permanently deleted.
924    *
925    * <p>Purge operations can take up to one minute to take effect. Tasks might be dispatched before
926    * the purge takes effect. A purge is irreversible.
927    *
928    * <p>Sample code:
929    *
930    * <pre>{@code
931    * // This snippet has been automatically generated and should be regarded as a code template only.
932    * // It will require modifications to work:
933    * // - It may require correct/in-range values for request initialization.
934    * // - It may require specifying regional endpoints when creating the service client as shown in
935    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
936    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
937    *   String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
938    *   Queue response = cloudTasksClient.purgeQueue(name);
939    * }
940    * }</pre>
941    *
942    * @param name Required. The queue name. For example:
943    *     `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
944    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
945    */
purgeQueue(String name)946   public final Queue purgeQueue(String name) {
947     PurgeQueueRequest request = PurgeQueueRequest.newBuilder().setName(name).build();
948     return purgeQueue(request);
949   }
950 
951   // AUTO-GENERATED DOCUMENTATION AND METHOD.
952   /**
953    * Purges a queue by deleting all of its tasks.
954    *
955    * <p>All tasks created before this method is called are permanently deleted.
956    *
957    * <p>Purge operations can take up to one minute to take effect. Tasks might be dispatched before
958    * the purge takes effect. A purge is irreversible.
959    *
960    * <p>Sample code:
961    *
962    * <pre>{@code
963    * // This snippet has been automatically generated and should be regarded as a code template only.
964    * // It will require modifications to work:
965    * // - It may require correct/in-range values for request initialization.
966    * // - It may require specifying regional endpoints when creating the service client as shown in
967    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
968    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
969    *   PurgeQueueRequest request =
970    *       PurgeQueueRequest.newBuilder()
971    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
972    *           .build();
973    *   Queue response = cloudTasksClient.purgeQueue(request);
974    * }
975    * }</pre>
976    *
977    * @param request The request object containing all of the parameters for the API call.
978    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
979    */
purgeQueue(PurgeQueueRequest request)980   public final Queue purgeQueue(PurgeQueueRequest request) {
981     return purgeQueueCallable().call(request);
982   }
983 
984   // AUTO-GENERATED DOCUMENTATION AND METHOD.
985   /**
986    * Purges a queue by deleting all of its tasks.
987    *
988    * <p>All tasks created before this method is called are permanently deleted.
989    *
990    * <p>Purge operations can take up to one minute to take effect. Tasks might be dispatched before
991    * the purge takes effect. A purge is irreversible.
992    *
993    * <p>Sample code:
994    *
995    * <pre>{@code
996    * // This snippet has been automatically generated and should be regarded as a code template only.
997    * // It will require modifications to work:
998    * // - It may require correct/in-range values for request initialization.
999    * // - It may require specifying regional endpoints when creating the service client as shown in
1000    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1001    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1002    *   PurgeQueueRequest request =
1003    *       PurgeQueueRequest.newBuilder()
1004    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1005    *           .build();
1006    *   ApiFuture<Queue> future = cloudTasksClient.purgeQueueCallable().futureCall(request);
1007    *   // Do something.
1008    *   Queue response = future.get();
1009    * }
1010    * }</pre>
1011    */
purgeQueueCallable()1012   public final UnaryCallable<PurgeQueueRequest, Queue> purgeQueueCallable() {
1013     return stub.purgeQueueCallable();
1014   }
1015 
1016   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1017   /**
1018    * Pauses the queue.
1019    *
1020    * <p>If a queue is paused then the system will stop dispatching tasks until the queue is resumed
1021    * via [ResumeQueue][google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue]. Tasks can still be added
1022    * when the queue is paused. A queue is paused if its
1023    * [state][google.cloud.tasks.v2beta3.Queue.state] is
1024    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED].
1025    *
1026    * <p>Sample code:
1027    *
1028    * <pre>{@code
1029    * // This snippet has been automatically generated and should be regarded as a code template only.
1030    * // It will require modifications to work:
1031    * // - It may require correct/in-range values for request initialization.
1032    * // - It may require specifying regional endpoints when creating the service client as shown in
1033    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1034    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1035    *   QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
1036    *   Queue response = cloudTasksClient.pauseQueue(name);
1037    * }
1038    * }</pre>
1039    *
1040    * @param name Required. The queue name. For example:
1041    *     `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1042    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1043    */
pauseQueue(QueueName name)1044   public final Queue pauseQueue(QueueName name) {
1045     PauseQueueRequest request =
1046         PauseQueueRequest.newBuilder().setName(name == null ? null : name.toString()).build();
1047     return pauseQueue(request);
1048   }
1049 
1050   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1051   /**
1052    * Pauses the queue.
1053    *
1054    * <p>If a queue is paused then the system will stop dispatching tasks until the queue is resumed
1055    * via [ResumeQueue][google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue]. Tasks can still be added
1056    * when the queue is paused. A queue is paused if its
1057    * [state][google.cloud.tasks.v2beta3.Queue.state] is
1058    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED].
1059    *
1060    * <p>Sample code:
1061    *
1062    * <pre>{@code
1063    * // This snippet has been automatically generated and should be regarded as a code template only.
1064    * // It will require modifications to work:
1065    * // - It may require correct/in-range values for request initialization.
1066    * // - It may require specifying regional endpoints when creating the service client as shown in
1067    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1068    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1069    *   String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
1070    *   Queue response = cloudTasksClient.pauseQueue(name);
1071    * }
1072    * }</pre>
1073    *
1074    * @param name Required. The queue name. For example:
1075    *     `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1076    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1077    */
pauseQueue(String name)1078   public final Queue pauseQueue(String name) {
1079     PauseQueueRequest request = PauseQueueRequest.newBuilder().setName(name).build();
1080     return pauseQueue(request);
1081   }
1082 
1083   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1084   /**
1085    * Pauses the queue.
1086    *
1087    * <p>If a queue is paused then the system will stop dispatching tasks until the queue is resumed
1088    * via [ResumeQueue][google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue]. Tasks can still be added
1089    * when the queue is paused. A queue is paused if its
1090    * [state][google.cloud.tasks.v2beta3.Queue.state] is
1091    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED].
1092    *
1093    * <p>Sample code:
1094    *
1095    * <pre>{@code
1096    * // This snippet has been automatically generated and should be regarded as a code template only.
1097    * // It will require modifications to work:
1098    * // - It may require correct/in-range values for request initialization.
1099    * // - It may require specifying regional endpoints when creating the service client as shown in
1100    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1101    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1102    *   PauseQueueRequest request =
1103    *       PauseQueueRequest.newBuilder()
1104    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1105    *           .build();
1106    *   Queue response = cloudTasksClient.pauseQueue(request);
1107    * }
1108    * }</pre>
1109    *
1110    * @param request The request object containing all of the parameters for the API call.
1111    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1112    */
pauseQueue(PauseQueueRequest request)1113   public final Queue pauseQueue(PauseQueueRequest request) {
1114     return pauseQueueCallable().call(request);
1115   }
1116 
1117   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1118   /**
1119    * Pauses the queue.
1120    *
1121    * <p>If a queue is paused then the system will stop dispatching tasks until the queue is resumed
1122    * via [ResumeQueue][google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue]. Tasks can still be added
1123    * when the queue is paused. A queue is paused if its
1124    * [state][google.cloud.tasks.v2beta3.Queue.state] is
1125    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED].
1126    *
1127    * <p>Sample code:
1128    *
1129    * <pre>{@code
1130    * // This snippet has been automatically generated and should be regarded as a code template only.
1131    * // It will require modifications to work:
1132    * // - It may require correct/in-range values for request initialization.
1133    * // - It may require specifying regional endpoints when creating the service client as shown in
1134    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1135    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1136    *   PauseQueueRequest request =
1137    *       PauseQueueRequest.newBuilder()
1138    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1139    *           .build();
1140    *   ApiFuture<Queue> future = cloudTasksClient.pauseQueueCallable().futureCall(request);
1141    *   // Do something.
1142    *   Queue response = future.get();
1143    * }
1144    * }</pre>
1145    */
pauseQueueCallable()1146   public final UnaryCallable<PauseQueueRequest, Queue> pauseQueueCallable() {
1147     return stub.pauseQueueCallable();
1148   }
1149 
1150   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1151   /**
1152    * Resume a queue.
1153    *
1154    * <p>This method resumes a queue after it has been
1155    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED] or
1156    * [DISABLED][google.cloud.tasks.v2beta3.Queue.State.DISABLED]. The state of a queue is stored in
1157    * the queue's [state][google.cloud.tasks.v2beta3.Queue.state]; after calling this method it will
1158    * be set to [RUNNING][google.cloud.tasks.v2beta3.Queue.State.RUNNING].
1159    *
1160    * <p>WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If
1161    * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud
1162    * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
1163    *
1164    * <p>Sample code:
1165    *
1166    * <pre>{@code
1167    * // This snippet has been automatically generated and should be regarded as a code template only.
1168    * // It will require modifications to work:
1169    * // - It may require correct/in-range values for request initialization.
1170    * // - It may require specifying regional endpoints when creating the service client as shown in
1171    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1172    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1173    *   QueueName name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
1174    *   Queue response = cloudTasksClient.resumeQueue(name);
1175    * }
1176    * }</pre>
1177    *
1178    * @param name Required. The queue name. For example:
1179    *     `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1180    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1181    */
resumeQueue(QueueName name)1182   public final Queue resumeQueue(QueueName name) {
1183     ResumeQueueRequest request =
1184         ResumeQueueRequest.newBuilder().setName(name == null ? null : name.toString()).build();
1185     return resumeQueue(request);
1186   }
1187 
1188   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1189   /**
1190    * Resume a queue.
1191    *
1192    * <p>This method resumes a queue after it has been
1193    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED] or
1194    * [DISABLED][google.cloud.tasks.v2beta3.Queue.State.DISABLED]. The state of a queue is stored in
1195    * the queue's [state][google.cloud.tasks.v2beta3.Queue.state]; after calling this method it will
1196    * be set to [RUNNING][google.cloud.tasks.v2beta3.Queue.State.RUNNING].
1197    *
1198    * <p>WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If
1199    * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud
1200    * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
1201    *
1202    * <p>Sample code:
1203    *
1204    * <pre>{@code
1205    * // This snippet has been automatically generated and should be regarded as a code template only.
1206    * // It will require modifications to work:
1207    * // - It may require correct/in-range values for request initialization.
1208    * // - It may require specifying regional endpoints when creating the service client as shown in
1209    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1210    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1211    *   String name = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
1212    *   Queue response = cloudTasksClient.resumeQueue(name);
1213    * }
1214    * }</pre>
1215    *
1216    * @param name Required. The queue name. For example:
1217    *     `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1218    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1219    */
resumeQueue(String name)1220   public final Queue resumeQueue(String name) {
1221     ResumeQueueRequest request = ResumeQueueRequest.newBuilder().setName(name).build();
1222     return resumeQueue(request);
1223   }
1224 
1225   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1226   /**
1227    * Resume a queue.
1228    *
1229    * <p>This method resumes a queue after it has been
1230    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED] or
1231    * [DISABLED][google.cloud.tasks.v2beta3.Queue.State.DISABLED]. The state of a queue is stored in
1232    * the queue's [state][google.cloud.tasks.v2beta3.Queue.state]; after calling this method it will
1233    * be set to [RUNNING][google.cloud.tasks.v2beta3.Queue.State.RUNNING].
1234    *
1235    * <p>WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If
1236    * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud
1237    * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
1238    *
1239    * <p>Sample code:
1240    *
1241    * <pre>{@code
1242    * // This snippet has been automatically generated and should be regarded as a code template only.
1243    * // It will require modifications to work:
1244    * // - It may require correct/in-range values for request initialization.
1245    * // - It may require specifying regional endpoints when creating the service client as shown in
1246    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1247    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1248    *   ResumeQueueRequest request =
1249    *       ResumeQueueRequest.newBuilder()
1250    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1251    *           .build();
1252    *   Queue response = cloudTasksClient.resumeQueue(request);
1253    * }
1254    * }</pre>
1255    *
1256    * @param request The request object containing all of the parameters for the API call.
1257    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1258    */
resumeQueue(ResumeQueueRequest request)1259   public final Queue resumeQueue(ResumeQueueRequest request) {
1260     return resumeQueueCallable().call(request);
1261   }
1262 
1263   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1264   /**
1265    * Resume a queue.
1266    *
1267    * <p>This method resumes a queue after it has been
1268    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED] or
1269    * [DISABLED][google.cloud.tasks.v2beta3.Queue.State.DISABLED]. The state of a queue is stored in
1270    * the queue's [state][google.cloud.tasks.v2beta3.Queue.state]; after calling this method it will
1271    * be set to [RUNNING][google.cloud.tasks.v2beta3.Queue.State.RUNNING].
1272    *
1273    * <p>WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If
1274    * you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud
1275    * Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
1276    *
1277    * <p>Sample code:
1278    *
1279    * <pre>{@code
1280    * // This snippet has been automatically generated and should be regarded as a code template only.
1281    * // It will require modifications to work:
1282    * // - It may require correct/in-range values for request initialization.
1283    * // - It may require specifying regional endpoints when creating the service client as shown in
1284    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1285    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1286    *   ResumeQueueRequest request =
1287    *       ResumeQueueRequest.newBuilder()
1288    *           .setName(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1289    *           .build();
1290    *   ApiFuture<Queue> future = cloudTasksClient.resumeQueueCallable().futureCall(request);
1291    *   // Do something.
1292    *   Queue response = future.get();
1293    * }
1294    * }</pre>
1295    */
resumeQueueCallable()1296   public final UnaryCallable<ResumeQueueRequest, Queue> resumeQueueCallable() {
1297     return stub.resumeQueueCallable();
1298   }
1299 
1300   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1301   /**
1302    * Gets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Returns an
1303    * empty policy if the resource exists and does not have a policy set.
1304    *
1305    * <p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
1306    * on the specified resource parent:
1307    *
1308    * <ul>
1309    *   <li>`cloudtasks.queues.getIamPolicy`
1310    * </ul>
1311    *
1312    * <p>Sample code:
1313    *
1314    * <pre>{@code
1315    * // This snippet has been automatically generated and should be regarded as a code template only.
1316    * // It will require modifications to work:
1317    * // - It may require correct/in-range values for request initialization.
1318    * // - It may require specifying regional endpoints when creating the service client as shown in
1319    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1320    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1321    *   ResourceName resource = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
1322    *   Policy response = cloudTasksClient.getIamPolicy(resource);
1323    * }
1324    * }</pre>
1325    *
1326    * @param resource REQUIRED: The resource for which the policy is being requested. See the
1327    *     operation documentation for the appropriate value for this field.
1328    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1329    */
getIamPolicy(ResourceName resource)1330   public final Policy getIamPolicy(ResourceName resource) {
1331     GetIamPolicyRequest request =
1332         GetIamPolicyRequest.newBuilder()
1333             .setResource(resource == null ? null : resource.toString())
1334             .build();
1335     return getIamPolicy(request);
1336   }
1337 
1338   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1339   /**
1340    * Gets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Returns an
1341    * empty policy if the resource exists and does not have a policy set.
1342    *
1343    * <p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
1344    * on the specified resource parent:
1345    *
1346    * <ul>
1347    *   <li>`cloudtasks.queues.getIamPolicy`
1348    * </ul>
1349    *
1350    * <p>Sample code:
1351    *
1352    * <pre>{@code
1353    * // This snippet has been automatically generated and should be regarded as a code template only.
1354    * // It will require modifications to work:
1355    * // - It may require correct/in-range values for request initialization.
1356    * // - It may require specifying regional endpoints when creating the service client as shown in
1357    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1358    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1359    *   String resource = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
1360    *   Policy response = cloudTasksClient.getIamPolicy(resource);
1361    * }
1362    * }</pre>
1363    *
1364    * @param resource REQUIRED: The resource for which the policy is being requested. See the
1365    *     operation documentation for the appropriate value for this field.
1366    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1367    */
getIamPolicy(String resource)1368   public final Policy getIamPolicy(String resource) {
1369     GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(resource).build();
1370     return getIamPolicy(request);
1371   }
1372 
1373   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1374   /**
1375    * Gets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Returns an
1376    * empty policy if the resource exists and does not have a policy set.
1377    *
1378    * <p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
1379    * on the specified resource parent:
1380    *
1381    * <ul>
1382    *   <li>`cloudtasks.queues.getIamPolicy`
1383    * </ul>
1384    *
1385    * <p>Sample code:
1386    *
1387    * <pre>{@code
1388    * // This snippet has been automatically generated and should be regarded as a code template only.
1389    * // It will require modifications to work:
1390    * // - It may require correct/in-range values for request initialization.
1391    * // - It may require specifying regional endpoints when creating the service client as shown in
1392    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1393    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1394    *   GetIamPolicyRequest request =
1395    *       GetIamPolicyRequest.newBuilder()
1396    *           .setResource(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1397    *           .setOptions(GetPolicyOptions.newBuilder().build())
1398    *           .build();
1399    *   Policy response = cloudTasksClient.getIamPolicy(request);
1400    * }
1401    * }</pre>
1402    *
1403    * @param request The request object containing all of the parameters for the API call.
1404    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1405    */
getIamPolicy(GetIamPolicyRequest request)1406   public final Policy getIamPolicy(GetIamPolicyRequest request) {
1407     return getIamPolicyCallable().call(request);
1408   }
1409 
getIamPolicy(QueueName queueName)1410   public final Policy getIamPolicy(QueueName queueName) {
1411     return getIamPolicy((ResourceName) queueName);
1412   }
1413 
1414   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1415   /**
1416    * Gets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Returns an
1417    * empty policy if the resource exists and does not have a policy set.
1418    *
1419    * <p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
1420    * on the specified resource parent:
1421    *
1422    * <ul>
1423    *   <li>`cloudtasks.queues.getIamPolicy`
1424    * </ul>
1425    *
1426    * <p>Sample code:
1427    *
1428    * <pre>{@code
1429    * // This snippet has been automatically generated and should be regarded as a code template only.
1430    * // It will require modifications to work:
1431    * // - It may require correct/in-range values for request initialization.
1432    * // - It may require specifying regional endpoints when creating the service client as shown in
1433    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1434    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1435    *   GetIamPolicyRequest request =
1436    *       GetIamPolicyRequest.newBuilder()
1437    *           .setResource(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1438    *           .setOptions(GetPolicyOptions.newBuilder().build())
1439    *           .build();
1440    *   ApiFuture<Policy> future = cloudTasksClient.getIamPolicyCallable().futureCall(request);
1441    *   // Do something.
1442    *   Policy response = future.get();
1443    * }
1444    * }</pre>
1445    */
getIamPolicyCallable()1446   public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
1447     return stub.getIamPolicyCallable();
1448   }
1449 
1450   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1451   /**
1452    * Sets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Replaces any
1453    * existing policy.
1454    *
1455    * <p>Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level
1456    * permissions are required to use the Cloud Console.
1457    *
1458    * <p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
1459    * on the specified resource parent:
1460    *
1461    * <ul>
1462    *   <li>`cloudtasks.queues.setIamPolicy`
1463    * </ul>
1464    *
1465    * <p>Sample code:
1466    *
1467    * <pre>{@code
1468    * // This snippet has been automatically generated and should be regarded as a code template only.
1469    * // It will require modifications to work:
1470    * // - It may require correct/in-range values for request initialization.
1471    * // - It may require specifying regional endpoints when creating the service client as shown in
1472    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1473    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1474    *   ResourceName resource = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
1475    *   Policy policy = Policy.newBuilder().build();
1476    *   Policy response = cloudTasksClient.setIamPolicy(resource, policy);
1477    * }
1478    * }</pre>
1479    *
1480    * @param resource REQUIRED: The resource for which the policy is being specified. See the
1481    *     operation documentation for the appropriate value for this field.
1482    * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
1483    *     policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
1484    *     Platform services (such as Projects) might reject them.
1485    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1486    */
setIamPolicy(ResourceName resource, Policy policy)1487   public final Policy setIamPolicy(ResourceName resource, Policy policy) {
1488     SetIamPolicyRequest request =
1489         SetIamPolicyRequest.newBuilder()
1490             .setResource(resource == null ? null : resource.toString())
1491             .setPolicy(policy)
1492             .build();
1493     return setIamPolicy(request);
1494   }
1495 
1496   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1497   /**
1498    * Sets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Replaces any
1499    * existing policy.
1500    *
1501    * <p>Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level
1502    * permissions are required to use the Cloud Console.
1503    *
1504    * <p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
1505    * on the specified resource parent:
1506    *
1507    * <ul>
1508    *   <li>`cloudtasks.queues.setIamPolicy`
1509    * </ul>
1510    *
1511    * <p>Sample code:
1512    *
1513    * <pre>{@code
1514    * // This snippet has been automatically generated and should be regarded as a code template only.
1515    * // It will require modifications to work:
1516    * // - It may require correct/in-range values for request initialization.
1517    * // - It may require specifying regional endpoints when creating the service client as shown in
1518    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1519    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1520    *   String resource = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
1521    *   Policy policy = Policy.newBuilder().build();
1522    *   Policy response = cloudTasksClient.setIamPolicy(resource, policy);
1523    * }
1524    * }</pre>
1525    *
1526    * @param resource REQUIRED: The resource for which the policy is being specified. See the
1527    *     operation documentation for the appropriate value for this field.
1528    * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
1529    *     policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
1530    *     Platform services (such as Projects) might reject them.
1531    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1532    */
setIamPolicy(String resource, Policy policy)1533   public final Policy setIamPolicy(String resource, Policy policy) {
1534     SetIamPolicyRequest request =
1535         SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build();
1536     return setIamPolicy(request);
1537   }
1538 
1539   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1540   /**
1541    * Sets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Replaces any
1542    * existing policy.
1543    *
1544    * <p>Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level
1545    * permissions are required to use the Cloud Console.
1546    *
1547    * <p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
1548    * on the specified resource parent:
1549    *
1550    * <ul>
1551    *   <li>`cloudtasks.queues.setIamPolicy`
1552    * </ul>
1553    *
1554    * <p>Sample code:
1555    *
1556    * <pre>{@code
1557    * // This snippet has been automatically generated and should be regarded as a code template only.
1558    * // It will require modifications to work:
1559    * // - It may require correct/in-range values for request initialization.
1560    * // - It may require specifying regional endpoints when creating the service client as shown in
1561    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1562    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1563    *   SetIamPolicyRequest request =
1564    *       SetIamPolicyRequest.newBuilder()
1565    *           .setResource(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1566    *           .setPolicy(Policy.newBuilder().build())
1567    *           .setUpdateMask(FieldMask.newBuilder().build())
1568    *           .build();
1569    *   Policy response = cloudTasksClient.setIamPolicy(request);
1570    * }
1571    * }</pre>
1572    *
1573    * @param request The request object containing all of the parameters for the API call.
1574    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1575    */
setIamPolicy(SetIamPolicyRequest request)1576   public final Policy setIamPolicy(SetIamPolicyRequest request) {
1577     return setIamPolicyCallable().call(request);
1578   }
1579 
setIamPolicy(QueueName queue, Policy policy)1580   public final Policy setIamPolicy(QueueName queue, Policy policy) {
1581     return setIamPolicy((ResourceName) queue, policy);
1582   }
1583 
1584   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1585   /**
1586    * Sets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Replaces any
1587    * existing policy.
1588    *
1589    * <p>Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level
1590    * permissions are required to use the Cloud Console.
1591    *
1592    * <p>Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission
1593    * on the specified resource parent:
1594    *
1595    * <ul>
1596    *   <li>`cloudtasks.queues.setIamPolicy`
1597    * </ul>
1598    *
1599    * <p>Sample code:
1600    *
1601    * <pre>{@code
1602    * // This snippet has been automatically generated and should be regarded as a code template only.
1603    * // It will require modifications to work:
1604    * // - It may require correct/in-range values for request initialization.
1605    * // - It may require specifying regional endpoints when creating the service client as shown in
1606    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1607    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1608    *   SetIamPolicyRequest request =
1609    *       SetIamPolicyRequest.newBuilder()
1610    *           .setResource(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1611    *           .setPolicy(Policy.newBuilder().build())
1612    *           .setUpdateMask(FieldMask.newBuilder().build())
1613    *           .build();
1614    *   ApiFuture<Policy> future = cloudTasksClient.setIamPolicyCallable().futureCall(request);
1615    *   // Do something.
1616    *   Policy response = future.get();
1617    * }
1618    * }</pre>
1619    */
setIamPolicyCallable()1620   public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
1621     return stub.setIamPolicyCallable();
1622   }
1623 
1624   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1625   /**
1626    * Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta3.Queue]. If the
1627    * resource does not exist, this will return an empty set of permissions, not a
1628    * [NOT_FOUND][google.rpc.Code.NOT_FOUND] error.
1629    *
1630    * <p>Note: This operation is designed to be used for building permission-aware UIs and
1631    * command-line tools, not for authorization checking. This operation may "fail open" without
1632    * warning.
1633    *
1634    * <p>Sample code:
1635    *
1636    * <pre>{@code
1637    * // This snippet has been automatically generated and should be regarded as a code template only.
1638    * // It will require modifications to work:
1639    * // - It may require correct/in-range values for request initialization.
1640    * // - It may require specifying regional endpoints when creating the service client as shown in
1641    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1642    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1643    *   ResourceName resource = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
1644    *   List<String> permissions = new ArrayList<>();
1645    *   TestIamPermissionsResponse response =
1646    *       cloudTasksClient.testIamPermissions(resource, permissions);
1647    * }
1648    * }</pre>
1649    *
1650    * @param resource REQUIRED: The resource for which the policy detail is being requested. See the
1651    *     operation documentation for the appropriate value for this field.
1652    * @param permissions The set of permissions to check for the `resource`. Permissions with
1653    *     wildcards (such as '&#42;' or 'storage.&#42;') are not allowed. For more information see
1654    *     [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1655    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1656    */
testIamPermissions( ResourceName resource, List<String> permissions)1657   public final TestIamPermissionsResponse testIamPermissions(
1658       ResourceName resource, List<String> permissions) {
1659     TestIamPermissionsRequest request =
1660         TestIamPermissionsRequest.newBuilder()
1661             .setResource(resource == null ? null : resource.toString())
1662             .addAllPermissions(permissions)
1663             .build();
1664     return testIamPermissions(request);
1665   }
1666 
1667   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1668   /**
1669    * Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta3.Queue]. If the
1670    * resource does not exist, this will return an empty set of permissions, not a
1671    * [NOT_FOUND][google.rpc.Code.NOT_FOUND] error.
1672    *
1673    * <p>Note: This operation is designed to be used for building permission-aware UIs and
1674    * command-line tools, not for authorization checking. This operation may "fail open" without
1675    * warning.
1676    *
1677    * <p>Sample code:
1678    *
1679    * <pre>{@code
1680    * // This snippet has been automatically generated and should be regarded as a code template only.
1681    * // It will require modifications to work:
1682    * // - It may require correct/in-range values for request initialization.
1683    * // - It may require specifying regional endpoints when creating the service client as shown in
1684    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1685    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1686    *   String resource = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
1687    *   List<String> permissions = new ArrayList<>();
1688    *   TestIamPermissionsResponse response =
1689    *       cloudTasksClient.testIamPermissions(resource, permissions);
1690    * }
1691    * }</pre>
1692    *
1693    * @param resource REQUIRED: The resource for which the policy detail is being requested. See the
1694    *     operation documentation for the appropriate value for this field.
1695    * @param permissions The set of permissions to check for the `resource`. Permissions with
1696    *     wildcards (such as '&#42;' or 'storage.&#42;') are not allowed. For more information see
1697    *     [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1698    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1699    */
testIamPermissions( String resource, List<String> permissions)1700   public final TestIamPermissionsResponse testIamPermissions(
1701       String resource, List<String> permissions) {
1702     TestIamPermissionsRequest request =
1703         TestIamPermissionsRequest.newBuilder()
1704             .setResource(resource)
1705             .addAllPermissions(permissions)
1706             .build();
1707     return testIamPermissions(request);
1708   }
1709 
1710   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1711   /**
1712    * Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta3.Queue]. If the
1713    * resource does not exist, this will return an empty set of permissions, not a
1714    * [NOT_FOUND][google.rpc.Code.NOT_FOUND] error.
1715    *
1716    * <p>Note: This operation is designed to be used for building permission-aware UIs and
1717    * command-line tools, not for authorization checking. This operation may "fail open" without
1718    * warning.
1719    *
1720    * <p>Sample code:
1721    *
1722    * <pre>{@code
1723    * // This snippet has been automatically generated and should be regarded as a code template only.
1724    * // It will require modifications to work:
1725    * // - It may require correct/in-range values for request initialization.
1726    * // - It may require specifying regional endpoints when creating the service client as shown in
1727    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1728    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1729    *   TestIamPermissionsRequest request =
1730    *       TestIamPermissionsRequest.newBuilder()
1731    *           .setResource(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1732    *           .addAllPermissions(new ArrayList<String>())
1733    *           .build();
1734    *   TestIamPermissionsResponse response = cloudTasksClient.testIamPermissions(request);
1735    * }
1736    * }</pre>
1737    *
1738    * @param request The request object containing all of the parameters for the API call.
1739    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1740    */
testIamPermissions(TestIamPermissionsRequest request)1741   public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) {
1742     return testIamPermissionsCallable().call(request);
1743   }
1744 
testIamPermissions( QueueName queue, List<String> permissions)1745   public final TestIamPermissionsResponse testIamPermissions(
1746       QueueName queue, List<String> permissions) {
1747     return testIamPermissions((ResourceName) queue, permissions);
1748   }
1749 
1750   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1751   /**
1752    * Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta3.Queue]. If the
1753    * resource does not exist, this will return an empty set of permissions, not a
1754    * [NOT_FOUND][google.rpc.Code.NOT_FOUND] error.
1755    *
1756    * <p>Note: This operation is designed to be used for building permission-aware UIs and
1757    * command-line tools, not for authorization checking. This operation may "fail open" without
1758    * warning.
1759    *
1760    * <p>Sample code:
1761    *
1762    * <pre>{@code
1763    * // This snippet has been automatically generated and should be regarded as a code template only.
1764    * // It will require modifications to work:
1765    * // - It may require correct/in-range values for request initialization.
1766    * // - It may require specifying regional endpoints when creating the service client as shown in
1767    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1768    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1769    *   TestIamPermissionsRequest request =
1770    *       TestIamPermissionsRequest.newBuilder()
1771    *           .setResource(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1772    *           .addAllPermissions(new ArrayList<String>())
1773    *           .build();
1774    *   ApiFuture<TestIamPermissionsResponse> future =
1775    *       cloudTasksClient.testIamPermissionsCallable().futureCall(request);
1776    *   // Do something.
1777    *   TestIamPermissionsResponse response = future.get();
1778    * }
1779    * }</pre>
1780    */
1781   public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable()1782       testIamPermissionsCallable() {
1783     return stub.testIamPermissionsCallable();
1784   }
1785 
1786   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1787   /**
1788    * Lists the tasks in a queue.
1789    *
1790    * <p>By default, only the [BASIC][google.cloud.tasks.v2beta3.Task.View.BASIC] view is retrieved
1791    * due to performance considerations;
1792    * [response_view][google.cloud.tasks.v2beta3.ListTasksRequest.response_view] controls the subset
1793    * of information which is returned.
1794    *
1795    * <p>The tasks may be returned in any order. The ordering may change at any time.
1796    *
1797    * <p>Sample code:
1798    *
1799    * <pre>{@code
1800    * // This snippet has been automatically generated and should be regarded as a code template only.
1801    * // It will require modifications to work:
1802    * // - It may require correct/in-range values for request initialization.
1803    * // - It may require specifying regional endpoints when creating the service client as shown in
1804    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1805    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1806    *   QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
1807    *   for (Task element : cloudTasksClient.listTasks(parent).iterateAll()) {
1808    *     // doThingsWith(element);
1809    *   }
1810    * }
1811    * }</pre>
1812    *
1813    * @param parent Required. The queue name. For example:
1814    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1815    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1816    */
listTasks(QueueName parent)1817   public final ListTasksPagedResponse listTasks(QueueName parent) {
1818     ListTasksRequest request =
1819         ListTasksRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build();
1820     return listTasks(request);
1821   }
1822 
1823   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1824   /**
1825    * Lists the tasks in a queue.
1826    *
1827    * <p>By default, only the [BASIC][google.cloud.tasks.v2beta3.Task.View.BASIC] view is retrieved
1828    * due to performance considerations;
1829    * [response_view][google.cloud.tasks.v2beta3.ListTasksRequest.response_view] controls the subset
1830    * of information which is returned.
1831    *
1832    * <p>The tasks may be returned in any order. The ordering may change at any time.
1833    *
1834    * <p>Sample code:
1835    *
1836    * <pre>{@code
1837    * // This snippet has been automatically generated and should be regarded as a code template only.
1838    * // It will require modifications to work:
1839    * // - It may require correct/in-range values for request initialization.
1840    * // - It may require specifying regional endpoints when creating the service client as shown in
1841    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1842    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1843    *   String parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
1844    *   for (Task element : cloudTasksClient.listTasks(parent).iterateAll()) {
1845    *     // doThingsWith(element);
1846    *   }
1847    * }
1848    * }</pre>
1849    *
1850    * @param parent Required. The queue name. For example:
1851    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1852    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1853    */
listTasks(String parent)1854   public final ListTasksPagedResponse listTasks(String parent) {
1855     ListTasksRequest request = ListTasksRequest.newBuilder().setParent(parent).build();
1856     return listTasks(request);
1857   }
1858 
1859   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1860   /**
1861    * Lists the tasks in a queue.
1862    *
1863    * <p>By default, only the [BASIC][google.cloud.tasks.v2beta3.Task.View.BASIC] view is retrieved
1864    * due to performance considerations;
1865    * [response_view][google.cloud.tasks.v2beta3.ListTasksRequest.response_view] controls the subset
1866    * of information which is returned.
1867    *
1868    * <p>The tasks may be returned in any order. The ordering may change at any time.
1869    *
1870    * <p>Sample code:
1871    *
1872    * <pre>{@code
1873    * // This snippet has been automatically generated and should be regarded as a code template only.
1874    * // It will require modifications to work:
1875    * // - It may require correct/in-range values for request initialization.
1876    * // - It may require specifying regional endpoints when creating the service client as shown in
1877    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1878    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1879    *   ListTasksRequest request =
1880    *       ListTasksRequest.newBuilder()
1881    *           .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1882    *           .setPageSize(883849137)
1883    *           .setPageToken("pageToken873572522")
1884    *           .build();
1885    *   for (Task element : cloudTasksClient.listTasks(request).iterateAll()) {
1886    *     // doThingsWith(element);
1887    *   }
1888    * }
1889    * }</pre>
1890    *
1891    * @param request The request object containing all of the parameters for the API call.
1892    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1893    */
listTasks(ListTasksRequest request)1894   public final ListTasksPagedResponse listTasks(ListTasksRequest request) {
1895     return listTasksPagedCallable().call(request);
1896   }
1897 
1898   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1899   /**
1900    * Lists the tasks in a queue.
1901    *
1902    * <p>By default, only the [BASIC][google.cloud.tasks.v2beta3.Task.View.BASIC] view is retrieved
1903    * due to performance considerations;
1904    * [response_view][google.cloud.tasks.v2beta3.ListTasksRequest.response_view] controls the subset
1905    * of information which is returned.
1906    *
1907    * <p>The tasks may be returned in any order. The ordering may change at any time.
1908    *
1909    * <p>Sample code:
1910    *
1911    * <pre>{@code
1912    * // This snippet has been automatically generated and should be regarded as a code template only.
1913    * // It will require modifications to work:
1914    * // - It may require correct/in-range values for request initialization.
1915    * // - It may require specifying regional endpoints when creating the service client as shown in
1916    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1917    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1918    *   ListTasksRequest request =
1919    *       ListTasksRequest.newBuilder()
1920    *           .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1921    *           .setPageSize(883849137)
1922    *           .setPageToken("pageToken873572522")
1923    *           .build();
1924    *   ApiFuture<Task> future = cloudTasksClient.listTasksPagedCallable().futureCall(request);
1925    *   // Do something.
1926    *   for (Task element : future.get().iterateAll()) {
1927    *     // doThingsWith(element);
1928    *   }
1929    * }
1930    * }</pre>
1931    */
listTasksPagedCallable()1932   public final UnaryCallable<ListTasksRequest, ListTasksPagedResponse> listTasksPagedCallable() {
1933     return stub.listTasksPagedCallable();
1934   }
1935 
1936   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1937   /**
1938    * Lists the tasks in a queue.
1939    *
1940    * <p>By default, only the [BASIC][google.cloud.tasks.v2beta3.Task.View.BASIC] view is retrieved
1941    * due to performance considerations;
1942    * [response_view][google.cloud.tasks.v2beta3.ListTasksRequest.response_view] controls the subset
1943    * of information which is returned.
1944    *
1945    * <p>The tasks may be returned in any order. The ordering may change at any time.
1946    *
1947    * <p>Sample code:
1948    *
1949    * <pre>{@code
1950    * // This snippet has been automatically generated and should be regarded as a code template only.
1951    * // It will require modifications to work:
1952    * // - It may require correct/in-range values for request initialization.
1953    * // - It may require specifying regional endpoints when creating the service client as shown in
1954    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1955    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1956    *   ListTasksRequest request =
1957    *       ListTasksRequest.newBuilder()
1958    *           .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
1959    *           .setPageSize(883849137)
1960    *           .setPageToken("pageToken873572522")
1961    *           .build();
1962    *   while (true) {
1963    *     ListTasksResponse response = cloudTasksClient.listTasksCallable().call(request);
1964    *     for (Task element : response.getTasksList()) {
1965    *       // doThingsWith(element);
1966    *     }
1967    *     String nextPageToken = response.getNextPageToken();
1968    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
1969    *       request = request.toBuilder().setPageToken(nextPageToken).build();
1970    *     } else {
1971    *       break;
1972    *     }
1973    *   }
1974    * }
1975    * }</pre>
1976    */
listTasksCallable()1977   public final UnaryCallable<ListTasksRequest, ListTasksResponse> listTasksCallable() {
1978     return stub.listTasksCallable();
1979   }
1980 
1981   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1982   /**
1983    * Gets a task.
1984    *
1985    * <p>Sample code:
1986    *
1987    * <pre>{@code
1988    * // This snippet has been automatically generated and should be regarded as a code template only.
1989    * // It will require modifications to work:
1990    * // - It may require correct/in-range values for request initialization.
1991    * // - It may require specifying regional endpoints when creating the service client as shown in
1992    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1993    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
1994    *   TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]");
1995    *   Task response = cloudTasksClient.getTask(name);
1996    * }
1997    * }</pre>
1998    *
1999    * @param name Required. The task name. For example:
2000    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2001    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2002    */
getTask(TaskName name)2003   public final Task getTask(TaskName name) {
2004     GetTaskRequest request =
2005         GetTaskRequest.newBuilder().setName(name == null ? null : name.toString()).build();
2006     return getTask(request);
2007   }
2008 
2009   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2010   /**
2011    * Gets a task.
2012    *
2013    * <p>Sample code:
2014    *
2015    * <pre>{@code
2016    * // This snippet has been automatically generated and should be regarded as a code template only.
2017    * // It will require modifications to work:
2018    * // - It may require correct/in-range values for request initialization.
2019    * // - It may require specifying regional endpoints when creating the service client as shown in
2020    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2021    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2022    *   String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString();
2023    *   Task response = cloudTasksClient.getTask(name);
2024    * }
2025    * }</pre>
2026    *
2027    * @param name Required. The task name. For example:
2028    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2029    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2030    */
getTask(String name)2031   public final Task getTask(String name) {
2032     GetTaskRequest request = GetTaskRequest.newBuilder().setName(name).build();
2033     return getTask(request);
2034   }
2035 
2036   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2037   /**
2038    * Gets a task.
2039    *
2040    * <p>Sample code:
2041    *
2042    * <pre>{@code
2043    * // This snippet has been automatically generated and should be regarded as a code template only.
2044    * // It will require modifications to work:
2045    * // - It may require correct/in-range values for request initialization.
2046    * // - It may require specifying regional endpoints when creating the service client as shown in
2047    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2048    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2049    *   GetTaskRequest request =
2050    *       GetTaskRequest.newBuilder()
2051    *           .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString())
2052    *           .build();
2053    *   Task response = cloudTasksClient.getTask(request);
2054    * }
2055    * }</pre>
2056    *
2057    * @param request The request object containing all of the parameters for the API call.
2058    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2059    */
getTask(GetTaskRequest request)2060   public final Task getTask(GetTaskRequest request) {
2061     return getTaskCallable().call(request);
2062   }
2063 
2064   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2065   /**
2066    * Gets a task.
2067    *
2068    * <p>Sample code:
2069    *
2070    * <pre>{@code
2071    * // This snippet has been automatically generated and should be regarded as a code template only.
2072    * // It will require modifications to work:
2073    * // - It may require correct/in-range values for request initialization.
2074    * // - It may require specifying regional endpoints when creating the service client as shown in
2075    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2076    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2077    *   GetTaskRequest request =
2078    *       GetTaskRequest.newBuilder()
2079    *           .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString())
2080    *           .build();
2081    *   ApiFuture<Task> future = cloudTasksClient.getTaskCallable().futureCall(request);
2082    *   // Do something.
2083    *   Task response = future.get();
2084    * }
2085    * }</pre>
2086    */
getTaskCallable()2087   public final UnaryCallable<GetTaskRequest, Task> getTaskCallable() {
2088     return stub.getTaskCallable();
2089   }
2090 
2091   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2092   /**
2093    * Creates a task and adds it to a queue.
2094    *
2095    * <p>Tasks cannot be updated after creation; there is no UpdateTask command.
2096    *
2097    * <ul>
2098    *   <li>The maximum task size is 100KB.
2099    * </ul>
2100    *
2101    * <p>Sample code:
2102    *
2103    * <pre>{@code
2104    * // This snippet has been automatically generated and should be regarded as a code template only.
2105    * // It will require modifications to work:
2106    * // - It may require correct/in-range values for request initialization.
2107    * // - It may require specifying regional endpoints when creating the service client as shown in
2108    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2109    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2110    *   QueueName parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]");
2111    *   Task task = Task.newBuilder().build();
2112    *   Task response = cloudTasksClient.createTask(parent, task);
2113    * }
2114    * }</pre>
2115    *
2116    * @param parent Required. The queue name. For example:
2117    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
2118    *     <p>The queue must already exist.
2119    * @param task Required. The task to add.
2120    *     <p>Task names have the following format:
2121    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. The user can
2122    *     optionally specify a task [name][google.cloud.tasks.v2beta3.Task.name]. If a name is not
2123    *     specified then the system will generate a random unique task id, which will be set in the
2124    *     task returned in the [response][google.cloud.tasks.v2beta3.Task.name].
2125    *     <p>If [schedule_time][google.cloud.tasks.v2beta3.Task.schedule_time] is not set or is in
2126    *     the past then Cloud Tasks will set it to the current time.
2127    *     <p>Task De-duplication:
2128    *     <p>Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical
2129    *     to that of an existing task or a task that was deleted or executed recently then the call
2130    *     will fail with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS]. If the task's queue was
2131    *     created using Cloud Tasks, then another task with the same name can't be created for ~1hour
2132    *     after the original task was deleted or executed. If the task's queue was created using
2133    *     queue.yaml or queue.xml, then another task with the same name can't be created for ~9days
2134    *     after the original task was deleted or executed.
2135    *     <p>Because there is an extra lookup cost to identify duplicate task names, these
2136    *     [CreateTask][google.cloud.tasks.v2beta3.CloudTasks.CreateTask] calls have significantly
2137    *     increased latency. Using hashed strings for the task id or for the prefix of the task id is
2138    *     recommended. Choosing task ids that are sequential or have sequential prefixes, for example
2139    *     using a timestamp, causes an increase in latency and error rates in all task commands. The
2140    *     infrastructure relies on an approximately uniform distribution of task ids to store and
2141    *     serve tasks efficiently.
2142    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2143    */
createTask(QueueName parent, Task task)2144   public final Task createTask(QueueName parent, Task task) {
2145     CreateTaskRequest request =
2146         CreateTaskRequest.newBuilder()
2147             .setParent(parent == null ? null : parent.toString())
2148             .setTask(task)
2149             .build();
2150     return createTask(request);
2151   }
2152 
2153   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2154   /**
2155    * Creates a task and adds it to a queue.
2156    *
2157    * <p>Tasks cannot be updated after creation; there is no UpdateTask command.
2158    *
2159    * <ul>
2160    *   <li>The maximum task size is 100KB.
2161    * </ul>
2162    *
2163    * <p>Sample code:
2164    *
2165    * <pre>{@code
2166    * // This snippet has been automatically generated and should be regarded as a code template only.
2167    * // It will require modifications to work:
2168    * // - It may require correct/in-range values for request initialization.
2169    * // - It may require specifying regional endpoints when creating the service client as shown in
2170    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2171    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2172    *   String parent = QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString();
2173    *   Task task = Task.newBuilder().build();
2174    *   Task response = cloudTasksClient.createTask(parent, task);
2175    * }
2176    * }</pre>
2177    *
2178    * @param parent Required. The queue name. For example:
2179    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
2180    *     <p>The queue must already exist.
2181    * @param task Required. The task to add.
2182    *     <p>Task names have the following format:
2183    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. The user can
2184    *     optionally specify a task [name][google.cloud.tasks.v2beta3.Task.name]. If a name is not
2185    *     specified then the system will generate a random unique task id, which will be set in the
2186    *     task returned in the [response][google.cloud.tasks.v2beta3.Task.name].
2187    *     <p>If [schedule_time][google.cloud.tasks.v2beta3.Task.schedule_time] is not set or is in
2188    *     the past then Cloud Tasks will set it to the current time.
2189    *     <p>Task De-duplication:
2190    *     <p>Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical
2191    *     to that of an existing task or a task that was deleted or executed recently then the call
2192    *     will fail with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS]. If the task's queue was
2193    *     created using Cloud Tasks, then another task with the same name can't be created for ~1hour
2194    *     after the original task was deleted or executed. If the task's queue was created using
2195    *     queue.yaml or queue.xml, then another task with the same name can't be created for ~9days
2196    *     after the original task was deleted or executed.
2197    *     <p>Because there is an extra lookup cost to identify duplicate task names, these
2198    *     [CreateTask][google.cloud.tasks.v2beta3.CloudTasks.CreateTask] calls have significantly
2199    *     increased latency. Using hashed strings for the task id or for the prefix of the task id is
2200    *     recommended. Choosing task ids that are sequential or have sequential prefixes, for example
2201    *     using a timestamp, causes an increase in latency and error rates in all task commands. The
2202    *     infrastructure relies on an approximately uniform distribution of task ids to store and
2203    *     serve tasks efficiently.
2204    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2205    */
createTask(String parent, Task task)2206   public final Task createTask(String parent, Task task) {
2207     CreateTaskRequest request =
2208         CreateTaskRequest.newBuilder().setParent(parent).setTask(task).build();
2209     return createTask(request);
2210   }
2211 
2212   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2213   /**
2214    * Creates a task and adds it to a queue.
2215    *
2216    * <p>Tasks cannot be updated after creation; there is no UpdateTask command.
2217    *
2218    * <ul>
2219    *   <li>The maximum task size is 100KB.
2220    * </ul>
2221    *
2222    * <p>Sample code:
2223    *
2224    * <pre>{@code
2225    * // This snippet has been automatically generated and should be regarded as a code template only.
2226    * // It will require modifications to work:
2227    * // - It may require correct/in-range values for request initialization.
2228    * // - It may require specifying regional endpoints when creating the service client as shown in
2229    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2230    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2231    *   CreateTaskRequest request =
2232    *       CreateTaskRequest.newBuilder()
2233    *           .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
2234    *           .setTask(Task.newBuilder().build())
2235    *           .build();
2236    *   Task response = cloudTasksClient.createTask(request);
2237    * }
2238    * }</pre>
2239    *
2240    * @param request The request object containing all of the parameters for the API call.
2241    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2242    */
createTask(CreateTaskRequest request)2243   public final Task createTask(CreateTaskRequest request) {
2244     return createTaskCallable().call(request);
2245   }
2246 
2247   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2248   /**
2249    * Creates a task and adds it to a queue.
2250    *
2251    * <p>Tasks cannot be updated after creation; there is no UpdateTask command.
2252    *
2253    * <ul>
2254    *   <li>The maximum task size is 100KB.
2255    * </ul>
2256    *
2257    * <p>Sample code:
2258    *
2259    * <pre>{@code
2260    * // This snippet has been automatically generated and should be regarded as a code template only.
2261    * // It will require modifications to work:
2262    * // - It may require correct/in-range values for request initialization.
2263    * // - It may require specifying regional endpoints when creating the service client as shown in
2264    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2265    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2266    *   CreateTaskRequest request =
2267    *       CreateTaskRequest.newBuilder()
2268    *           .setParent(QueueName.of("[PROJECT]", "[LOCATION]", "[QUEUE]").toString())
2269    *           .setTask(Task.newBuilder().build())
2270    *           .build();
2271    *   ApiFuture<Task> future = cloudTasksClient.createTaskCallable().futureCall(request);
2272    *   // Do something.
2273    *   Task response = future.get();
2274    * }
2275    * }</pre>
2276    */
createTaskCallable()2277   public final UnaryCallable<CreateTaskRequest, Task> createTaskCallable() {
2278     return stub.createTaskCallable();
2279   }
2280 
2281   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2282   /**
2283    * Deletes a task.
2284    *
2285    * <p>A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has
2286    * executed successfully or permanently failed.
2287    *
2288    * <p>Sample code:
2289    *
2290    * <pre>{@code
2291    * // This snippet has been automatically generated and should be regarded as a code template only.
2292    * // It will require modifications to work:
2293    * // - It may require correct/in-range values for request initialization.
2294    * // - It may require specifying regional endpoints when creating the service client as shown in
2295    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2296    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2297    *   TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]");
2298    *   cloudTasksClient.deleteTask(name);
2299    * }
2300    * }</pre>
2301    *
2302    * @param name Required. The task name. For example:
2303    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2304    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2305    */
deleteTask(TaskName name)2306   public final void deleteTask(TaskName name) {
2307     DeleteTaskRequest request =
2308         DeleteTaskRequest.newBuilder().setName(name == null ? null : name.toString()).build();
2309     deleteTask(request);
2310   }
2311 
2312   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2313   /**
2314    * Deletes a task.
2315    *
2316    * <p>A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has
2317    * executed successfully or permanently failed.
2318    *
2319    * <p>Sample code:
2320    *
2321    * <pre>{@code
2322    * // This snippet has been automatically generated and should be regarded as a code template only.
2323    * // It will require modifications to work:
2324    * // - It may require correct/in-range values for request initialization.
2325    * // - It may require specifying regional endpoints when creating the service client as shown in
2326    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2327    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2328    *   String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString();
2329    *   cloudTasksClient.deleteTask(name);
2330    * }
2331    * }</pre>
2332    *
2333    * @param name Required. The task name. For example:
2334    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2335    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2336    */
deleteTask(String name)2337   public final void deleteTask(String name) {
2338     DeleteTaskRequest request = DeleteTaskRequest.newBuilder().setName(name).build();
2339     deleteTask(request);
2340   }
2341 
2342   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2343   /**
2344    * Deletes a task.
2345    *
2346    * <p>A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has
2347    * executed successfully or permanently failed.
2348    *
2349    * <p>Sample code:
2350    *
2351    * <pre>{@code
2352    * // This snippet has been automatically generated and should be regarded as a code template only.
2353    * // It will require modifications to work:
2354    * // - It may require correct/in-range values for request initialization.
2355    * // - It may require specifying regional endpoints when creating the service client as shown in
2356    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2357    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2358    *   DeleteTaskRequest request =
2359    *       DeleteTaskRequest.newBuilder()
2360    *           .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString())
2361    *           .build();
2362    *   cloudTasksClient.deleteTask(request);
2363    * }
2364    * }</pre>
2365    *
2366    * @param request The request object containing all of the parameters for the API call.
2367    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2368    */
deleteTask(DeleteTaskRequest request)2369   public final void deleteTask(DeleteTaskRequest request) {
2370     deleteTaskCallable().call(request);
2371   }
2372 
2373   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2374   /**
2375    * Deletes a task.
2376    *
2377    * <p>A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has
2378    * executed successfully or permanently failed.
2379    *
2380    * <p>Sample code:
2381    *
2382    * <pre>{@code
2383    * // This snippet has been automatically generated and should be regarded as a code template only.
2384    * // It will require modifications to work:
2385    * // - It may require correct/in-range values for request initialization.
2386    * // - It may require specifying regional endpoints when creating the service client as shown in
2387    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2388    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2389    *   DeleteTaskRequest request =
2390    *       DeleteTaskRequest.newBuilder()
2391    *           .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString())
2392    *           .build();
2393    *   ApiFuture<Empty> future = cloudTasksClient.deleteTaskCallable().futureCall(request);
2394    *   // Do something.
2395    *   future.get();
2396    * }
2397    * }</pre>
2398    */
deleteTaskCallable()2399   public final UnaryCallable<DeleteTaskRequest, Empty> deleteTaskCallable() {
2400     return stub.deleteTaskCallable();
2401   }
2402 
2403   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2404   /**
2405    * Forces a task to run now.
2406    *
2407    * <p>When this method is called, Cloud Tasks will dispatch the task, even if the task is already
2408    * running, the queue has reached its [RateLimits][google.cloud.tasks.v2beta3.RateLimits] or is
2409    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED].
2410    *
2411    * <p>This command is meant to be used for manual debugging. For example,
2412    * [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] can be used to retry a failed task
2413    * after a fix has been made or to manually force a task to be dispatched now.
2414    *
2415    * <p>The dispatched task is returned. That is, the task that is returned contains the
2416    * [status][Task.status] after the task is dispatched but before the task is received by its
2417    * target.
2418    *
2419    * <p>If Cloud Tasks receives a successful response from the task's target, then the task will be
2420    * deleted; otherwise the task's [schedule_time][google.cloud.tasks.v2beta3.Task.schedule_time]
2421    * will be reset to the time that [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] was
2422    * called plus the retry delay specified in the queue's
2423    * [RetryConfig][google.cloud.tasks.v2beta3.RetryConfig].
2424    *
2425    * <p>[RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] returns
2426    * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded
2427    * or permanently failed.
2428    *
2429    * <p>Sample code:
2430    *
2431    * <pre>{@code
2432    * // This snippet has been automatically generated and should be regarded as a code template only.
2433    * // It will require modifications to work:
2434    * // - It may require correct/in-range values for request initialization.
2435    * // - It may require specifying regional endpoints when creating the service client as shown in
2436    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2437    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2438    *   TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]");
2439    *   Task response = cloudTasksClient.runTask(name);
2440    * }
2441    * }</pre>
2442    *
2443    * @param name Required. The task name. For example:
2444    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2445    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2446    */
runTask(TaskName name)2447   public final Task runTask(TaskName name) {
2448     RunTaskRequest request =
2449         RunTaskRequest.newBuilder().setName(name == null ? null : name.toString()).build();
2450     return runTask(request);
2451   }
2452 
2453   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2454   /**
2455    * Forces a task to run now.
2456    *
2457    * <p>When this method is called, Cloud Tasks will dispatch the task, even if the task is already
2458    * running, the queue has reached its [RateLimits][google.cloud.tasks.v2beta3.RateLimits] or is
2459    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED].
2460    *
2461    * <p>This command is meant to be used for manual debugging. For example,
2462    * [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] can be used to retry a failed task
2463    * after a fix has been made or to manually force a task to be dispatched now.
2464    *
2465    * <p>The dispatched task is returned. That is, the task that is returned contains the
2466    * [status][Task.status] after the task is dispatched but before the task is received by its
2467    * target.
2468    *
2469    * <p>If Cloud Tasks receives a successful response from the task's target, then the task will be
2470    * deleted; otherwise the task's [schedule_time][google.cloud.tasks.v2beta3.Task.schedule_time]
2471    * will be reset to the time that [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] was
2472    * called plus the retry delay specified in the queue's
2473    * [RetryConfig][google.cloud.tasks.v2beta3.RetryConfig].
2474    *
2475    * <p>[RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] returns
2476    * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded
2477    * or permanently failed.
2478    *
2479    * <p>Sample code:
2480    *
2481    * <pre>{@code
2482    * // This snippet has been automatically generated and should be regarded as a code template only.
2483    * // It will require modifications to work:
2484    * // - It may require correct/in-range values for request initialization.
2485    * // - It may require specifying regional endpoints when creating the service client as shown in
2486    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2487    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2488    *   String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString();
2489    *   Task response = cloudTasksClient.runTask(name);
2490    * }
2491    * }</pre>
2492    *
2493    * @param name Required. The task name. For example:
2494    *     `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2495    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2496    */
runTask(String name)2497   public final Task runTask(String name) {
2498     RunTaskRequest request = RunTaskRequest.newBuilder().setName(name).build();
2499     return runTask(request);
2500   }
2501 
2502   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2503   /**
2504    * Forces a task to run now.
2505    *
2506    * <p>When this method is called, Cloud Tasks will dispatch the task, even if the task is already
2507    * running, the queue has reached its [RateLimits][google.cloud.tasks.v2beta3.RateLimits] or is
2508    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED].
2509    *
2510    * <p>This command is meant to be used for manual debugging. For example,
2511    * [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] can be used to retry a failed task
2512    * after a fix has been made or to manually force a task to be dispatched now.
2513    *
2514    * <p>The dispatched task is returned. That is, the task that is returned contains the
2515    * [status][Task.status] after the task is dispatched but before the task is received by its
2516    * target.
2517    *
2518    * <p>If Cloud Tasks receives a successful response from the task's target, then the task will be
2519    * deleted; otherwise the task's [schedule_time][google.cloud.tasks.v2beta3.Task.schedule_time]
2520    * will be reset to the time that [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] was
2521    * called plus the retry delay specified in the queue's
2522    * [RetryConfig][google.cloud.tasks.v2beta3.RetryConfig].
2523    *
2524    * <p>[RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] returns
2525    * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded
2526    * or permanently failed.
2527    *
2528    * <p>Sample code:
2529    *
2530    * <pre>{@code
2531    * // This snippet has been automatically generated and should be regarded as a code template only.
2532    * // It will require modifications to work:
2533    * // - It may require correct/in-range values for request initialization.
2534    * // - It may require specifying regional endpoints when creating the service client as shown in
2535    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2536    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2537    *   RunTaskRequest request =
2538    *       RunTaskRequest.newBuilder()
2539    *           .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString())
2540    *           .build();
2541    *   Task response = cloudTasksClient.runTask(request);
2542    * }
2543    * }</pre>
2544    *
2545    * @param request The request object containing all of the parameters for the API call.
2546    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
2547    */
runTask(RunTaskRequest request)2548   public final Task runTask(RunTaskRequest request) {
2549     return runTaskCallable().call(request);
2550   }
2551 
2552   // AUTO-GENERATED DOCUMENTATION AND METHOD.
2553   /**
2554    * Forces a task to run now.
2555    *
2556    * <p>When this method is called, Cloud Tasks will dispatch the task, even if the task is already
2557    * running, the queue has reached its [RateLimits][google.cloud.tasks.v2beta3.RateLimits] or is
2558    * [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED].
2559    *
2560    * <p>This command is meant to be used for manual debugging. For example,
2561    * [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] can be used to retry a failed task
2562    * after a fix has been made or to manually force a task to be dispatched now.
2563    *
2564    * <p>The dispatched task is returned. That is, the task that is returned contains the
2565    * [status][Task.status] after the task is dispatched but before the task is received by its
2566    * target.
2567    *
2568    * <p>If Cloud Tasks receives a successful response from the task's target, then the task will be
2569    * deleted; otherwise the task's [schedule_time][google.cloud.tasks.v2beta3.Task.schedule_time]
2570    * will be reset to the time that [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] was
2571    * called plus the retry delay specified in the queue's
2572    * [RetryConfig][google.cloud.tasks.v2beta3.RetryConfig].
2573    *
2574    * <p>[RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask] returns
2575    * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded
2576    * or permanently failed.
2577    *
2578    * <p>Sample code:
2579    *
2580    * <pre>{@code
2581    * // This snippet has been automatically generated and should be regarded as a code template only.
2582    * // It will require modifications to work:
2583    * // - It may require correct/in-range values for request initialization.
2584    * // - It may require specifying regional endpoints when creating the service client as shown in
2585    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
2586    * try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
2587    *   RunTaskRequest request =
2588    *       RunTaskRequest.newBuilder()
2589    *           .setName(TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString())
2590    *           .build();
2591    *   ApiFuture<Task> future = cloudTasksClient.runTaskCallable().futureCall(request);
2592    *   // Do something.
2593    *   Task response = future.get();
2594    * }
2595    * }</pre>
2596    */
runTaskCallable()2597   public final UnaryCallable<RunTaskRequest, Task> runTaskCallable() {
2598     return stub.runTaskCallable();
2599   }
2600 
2601   @Override
close()2602   public final void close() {
2603     stub.close();
2604   }
2605 
2606   @Override
shutdown()2607   public void shutdown() {
2608     stub.shutdown();
2609   }
2610 
2611   @Override
isShutdown()2612   public boolean isShutdown() {
2613     return stub.isShutdown();
2614   }
2615 
2616   @Override
isTerminated()2617   public boolean isTerminated() {
2618     return stub.isTerminated();
2619   }
2620 
2621   @Override
shutdownNow()2622   public void shutdownNow() {
2623     stub.shutdownNow();
2624   }
2625 
2626   @Override
awaitTermination(long duration, TimeUnit unit)2627   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
2628     return stub.awaitTermination(duration, unit);
2629   }
2630 
2631   public static class ListQueuesPagedResponse
2632       extends AbstractPagedListResponse<
2633           ListQueuesRequest,
2634           ListQueuesResponse,
2635           Queue,
2636           ListQueuesPage,
2637           ListQueuesFixedSizeCollection> {
2638 
createAsync( PageContext<ListQueuesRequest, ListQueuesResponse, Queue> context, ApiFuture<ListQueuesResponse> futureResponse)2639     public static ApiFuture<ListQueuesPagedResponse> createAsync(
2640         PageContext<ListQueuesRequest, ListQueuesResponse, Queue> context,
2641         ApiFuture<ListQueuesResponse> futureResponse) {
2642       ApiFuture<ListQueuesPage> futurePage =
2643           ListQueuesPage.createEmptyPage().createPageAsync(context, futureResponse);
2644       return ApiFutures.transform(
2645           futurePage, input -> new ListQueuesPagedResponse(input), MoreExecutors.directExecutor());
2646     }
2647 
ListQueuesPagedResponse(ListQueuesPage page)2648     private ListQueuesPagedResponse(ListQueuesPage page) {
2649       super(page, ListQueuesFixedSizeCollection.createEmptyCollection());
2650     }
2651   }
2652 
2653   public static class ListQueuesPage
2654       extends AbstractPage<ListQueuesRequest, ListQueuesResponse, Queue, ListQueuesPage> {
2655 
ListQueuesPage( PageContext<ListQueuesRequest, ListQueuesResponse, Queue> context, ListQueuesResponse response)2656     private ListQueuesPage(
2657         PageContext<ListQueuesRequest, ListQueuesResponse, Queue> context,
2658         ListQueuesResponse response) {
2659       super(context, response);
2660     }
2661 
createEmptyPage()2662     private static ListQueuesPage createEmptyPage() {
2663       return new ListQueuesPage(null, null);
2664     }
2665 
2666     @Override
createPage( PageContext<ListQueuesRequest, ListQueuesResponse, Queue> context, ListQueuesResponse response)2667     protected ListQueuesPage createPage(
2668         PageContext<ListQueuesRequest, ListQueuesResponse, Queue> context,
2669         ListQueuesResponse response) {
2670       return new ListQueuesPage(context, response);
2671     }
2672 
2673     @Override
createPageAsync( PageContext<ListQueuesRequest, ListQueuesResponse, Queue> context, ApiFuture<ListQueuesResponse> futureResponse)2674     public ApiFuture<ListQueuesPage> createPageAsync(
2675         PageContext<ListQueuesRequest, ListQueuesResponse, Queue> context,
2676         ApiFuture<ListQueuesResponse> futureResponse) {
2677       return super.createPageAsync(context, futureResponse);
2678     }
2679   }
2680 
2681   public static class ListQueuesFixedSizeCollection
2682       extends AbstractFixedSizeCollection<
2683           ListQueuesRequest,
2684           ListQueuesResponse,
2685           Queue,
2686           ListQueuesPage,
2687           ListQueuesFixedSizeCollection> {
2688 
ListQueuesFixedSizeCollection(List<ListQueuesPage> pages, int collectionSize)2689     private ListQueuesFixedSizeCollection(List<ListQueuesPage> pages, int collectionSize) {
2690       super(pages, collectionSize);
2691     }
2692 
createEmptyCollection()2693     private static ListQueuesFixedSizeCollection createEmptyCollection() {
2694       return new ListQueuesFixedSizeCollection(null, 0);
2695     }
2696 
2697     @Override
createCollection( List<ListQueuesPage> pages, int collectionSize)2698     protected ListQueuesFixedSizeCollection createCollection(
2699         List<ListQueuesPage> pages, int collectionSize) {
2700       return new ListQueuesFixedSizeCollection(pages, collectionSize);
2701     }
2702   }
2703 
2704   public static class ListTasksPagedResponse
2705       extends AbstractPagedListResponse<
2706           ListTasksRequest, ListTasksResponse, Task, ListTasksPage, ListTasksFixedSizeCollection> {
2707 
createAsync( PageContext<ListTasksRequest, ListTasksResponse, Task> context, ApiFuture<ListTasksResponse> futureResponse)2708     public static ApiFuture<ListTasksPagedResponse> createAsync(
2709         PageContext<ListTasksRequest, ListTasksResponse, Task> context,
2710         ApiFuture<ListTasksResponse> futureResponse) {
2711       ApiFuture<ListTasksPage> futurePage =
2712           ListTasksPage.createEmptyPage().createPageAsync(context, futureResponse);
2713       return ApiFutures.transform(
2714           futurePage, input -> new ListTasksPagedResponse(input), MoreExecutors.directExecutor());
2715     }
2716 
ListTasksPagedResponse(ListTasksPage page)2717     private ListTasksPagedResponse(ListTasksPage page) {
2718       super(page, ListTasksFixedSizeCollection.createEmptyCollection());
2719     }
2720   }
2721 
2722   public static class ListTasksPage
2723       extends AbstractPage<ListTasksRequest, ListTasksResponse, Task, ListTasksPage> {
2724 
ListTasksPage( PageContext<ListTasksRequest, ListTasksResponse, Task> context, ListTasksResponse response)2725     private ListTasksPage(
2726         PageContext<ListTasksRequest, ListTasksResponse, Task> context,
2727         ListTasksResponse response) {
2728       super(context, response);
2729     }
2730 
createEmptyPage()2731     private static ListTasksPage createEmptyPage() {
2732       return new ListTasksPage(null, null);
2733     }
2734 
2735     @Override
createPage( PageContext<ListTasksRequest, ListTasksResponse, Task> context, ListTasksResponse response)2736     protected ListTasksPage createPage(
2737         PageContext<ListTasksRequest, ListTasksResponse, Task> context,
2738         ListTasksResponse response) {
2739       return new ListTasksPage(context, response);
2740     }
2741 
2742     @Override
createPageAsync( PageContext<ListTasksRequest, ListTasksResponse, Task> context, ApiFuture<ListTasksResponse> futureResponse)2743     public ApiFuture<ListTasksPage> createPageAsync(
2744         PageContext<ListTasksRequest, ListTasksResponse, Task> context,
2745         ApiFuture<ListTasksResponse> futureResponse) {
2746       return super.createPageAsync(context, futureResponse);
2747     }
2748   }
2749 
2750   public static class ListTasksFixedSizeCollection
2751       extends AbstractFixedSizeCollection<
2752           ListTasksRequest, ListTasksResponse, Task, ListTasksPage, ListTasksFixedSizeCollection> {
2753 
ListTasksFixedSizeCollection(List<ListTasksPage> pages, int collectionSize)2754     private ListTasksFixedSizeCollection(List<ListTasksPage> pages, int collectionSize) {
2755       super(pages, collectionSize);
2756     }
2757 
createEmptyCollection()2758     private static ListTasksFixedSizeCollection createEmptyCollection() {
2759       return new ListTasksFixedSizeCollection(null, 0);
2760     }
2761 
2762     @Override
createCollection( List<ListTasksPage> pages, int collectionSize)2763     protected ListTasksFixedSizeCollection createCollection(
2764         List<ListTasksPage> pages, int collectionSize) {
2765       return new ListTasksFixedSizeCollection(pages, collectionSize);
2766     }
2767   }
2768 }
2769