• 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.compute.v1;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.gax.core.BackgroundResource;
22 import com.google.api.gax.paging.AbstractFixedSizeCollection;
23 import com.google.api.gax.paging.AbstractPage;
24 import com.google.api.gax.paging.AbstractPagedListResponse;
25 import com.google.api.gax.rpc.PageContext;
26 import com.google.api.gax.rpc.UnaryCallable;
27 import com.google.cloud.compute.v1.stub.ZoneOperationsStub;
28 import com.google.cloud.compute.v1.stub.ZoneOperationsStubSettings;
29 import com.google.common.util.concurrent.MoreExecutors;
30 import java.io.IOException;
31 import java.util.List;
32 import java.util.concurrent.TimeUnit;
33 import javax.annotation.Generated;
34 
35 // AUTO-GENERATED DOCUMENTATION AND CLASS.
36 /**
37  * Service Description: The ZoneOperations API.
38  *
39  * <p>This class provides the ability to make remote calls to the backing service through method
40  * calls that map to API methods. Sample code to get started:
41  *
42  * <pre>{@code
43  * // This snippet has been automatically generated and should be regarded as a code template only.
44  * // It will require modifications to work:
45  * // - It may require correct/in-range values for request initialization.
46  * // - It may require specifying regional endpoints when creating the service client as shown in
47  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
48  * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
49  *   String project = "project-309310695";
50  *   String zone = "zone3744684";
51  *   String operation = "operation1662702951";
52  *   DeleteZoneOperationResponse response = zoneOperationsClient.delete(project, zone, operation);
53  * }
54  * }</pre>
55  *
56  * <p>Note: close() needs to be called on the ZoneOperationsClient object to clean up resources such
57  * as threads. In the example above, try-with-resources is used, which automatically calls close().
58  *
59  * <p>The surface of this class includes several types of Java methods for each of the API's
60  * methods:
61  *
62  * <ol>
63  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
64  *       converted into function parameters. It may be the case that not all fields are available as
65  *       parameters, and not every API method will have a flattened method entry point.
66  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
67  *       which must be constructed before the call. Not every API method will have a request object
68  *       method.
69  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
70  *       callable object, which can be used to initiate calls to the service.
71  * </ol>
72  *
73  * <p>See the individual methods for example code.
74  *
75  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
76  * these names, this class includes a format method for each type of name, and additionally a parse
77  * method to extract the individual identifiers contained within names that are returned.
78  *
79  * <p>This class can be customized by passing in a custom instance of ZoneOperationsSettings to
80  * create(). For example:
81  *
82  * <p>To customize credentials:
83  *
84  * <pre>{@code
85  * // This snippet has been automatically generated and should be regarded as a code template only.
86  * // It will require modifications to work:
87  * // - It may require correct/in-range values for request initialization.
88  * // - It may require specifying regional endpoints when creating the service client as shown in
89  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
90  * ZoneOperationsSettings zoneOperationsSettings =
91  *     ZoneOperationsSettings.newBuilder()
92  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
93  *         .build();
94  * ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create(zoneOperationsSettings);
95  * }</pre>
96  *
97  * <p>To customize the endpoint:
98  *
99  * <pre>{@code
100  * // This snippet has been automatically generated and should be regarded as a code template only.
101  * // It will require modifications to work:
102  * // - It may require correct/in-range values for request initialization.
103  * // - It may require specifying regional endpoints when creating the service client as shown in
104  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
105  * ZoneOperationsSettings zoneOperationsSettings =
106  *     ZoneOperationsSettings.newBuilder().setEndpoint(myEndpoint).build();
107  * ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create(zoneOperationsSettings);
108  * }</pre>
109  *
110  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
111  */
112 @Generated("by gapic-generator-java")
113 public class ZoneOperationsClient implements BackgroundResource {
114   private final ZoneOperationsSettings settings;
115   private final ZoneOperationsStub stub;
116 
117   /** Constructs an instance of ZoneOperationsClient with default settings. */
create()118   public static final ZoneOperationsClient create() throws IOException {
119     return create(ZoneOperationsSettings.newBuilder().build());
120   }
121 
122   /**
123    * Constructs an instance of ZoneOperationsClient, using the given settings. The channels are
124    * created based on the settings passed in, or defaults for any settings that are not set.
125    */
create(ZoneOperationsSettings settings)126   public static final ZoneOperationsClient create(ZoneOperationsSettings settings)
127       throws IOException {
128     return new ZoneOperationsClient(settings);
129   }
130 
131   /**
132    * Constructs an instance of ZoneOperationsClient, using the given stub for making calls. This is
133    * for advanced usage - prefer using create(ZoneOperationsSettings).
134    */
create(ZoneOperationsStub stub)135   public static final ZoneOperationsClient create(ZoneOperationsStub stub) {
136     return new ZoneOperationsClient(stub);
137   }
138 
139   /**
140    * Constructs an instance of ZoneOperationsClient, using the given settings. This is protected so
141    * that it is easy to make a subclass, but otherwise, the static factory methods should be
142    * preferred.
143    */
ZoneOperationsClient(ZoneOperationsSettings settings)144   protected ZoneOperationsClient(ZoneOperationsSettings settings) throws IOException {
145     this.settings = settings;
146     this.stub = ((ZoneOperationsStubSettings) settings.getStubSettings()).createStub();
147   }
148 
ZoneOperationsClient(ZoneOperationsStub stub)149   protected ZoneOperationsClient(ZoneOperationsStub stub) {
150     this.settings = null;
151     this.stub = stub;
152   }
153 
getSettings()154   public final ZoneOperationsSettings getSettings() {
155     return settings;
156   }
157 
getStub()158   public ZoneOperationsStub getStub() {
159     return stub;
160   }
161 
162   // AUTO-GENERATED DOCUMENTATION AND METHOD.
163   /**
164    * Deletes the specified zone-specific Operations resource.
165    *
166    * <p>Sample code:
167    *
168    * <pre>{@code
169    * // This snippet has been automatically generated and should be regarded as a code template only.
170    * // It will require modifications to work:
171    * // - It may require correct/in-range values for request initialization.
172    * // - It may require specifying regional endpoints when creating the service client as shown in
173    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
174    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
175    *   String project = "project-309310695";
176    *   String zone = "zone3744684";
177    *   String operation = "operation1662702951";
178    *   DeleteZoneOperationResponse response = zoneOperationsClient.delete(project, zone, operation);
179    * }
180    * }</pre>
181    *
182    * @param project Project ID for this request.
183    * @param zone Name of the zone for this request.
184    * @param operation Name of the Operations resource to delete.
185    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
186    */
delete(String project, String zone, String operation)187   public final DeleteZoneOperationResponse delete(String project, String zone, String operation) {
188     DeleteZoneOperationRequest request =
189         DeleteZoneOperationRequest.newBuilder()
190             .setProject(project)
191             .setZone(zone)
192             .setOperation(operation)
193             .build();
194     return delete(request);
195   }
196 
197   // AUTO-GENERATED DOCUMENTATION AND METHOD.
198   /**
199    * Deletes the specified zone-specific Operations resource.
200    *
201    * <p>Sample code:
202    *
203    * <pre>{@code
204    * // This snippet has been automatically generated and should be regarded as a code template only.
205    * // It will require modifications to work:
206    * // - It may require correct/in-range values for request initialization.
207    * // - It may require specifying regional endpoints when creating the service client as shown in
208    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
209    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
210    *   DeleteZoneOperationRequest request =
211    *       DeleteZoneOperationRequest.newBuilder()
212    *           .setOperation("operation1662702951")
213    *           .setProject("project-309310695")
214    *           .setZone("zone3744684")
215    *           .build();
216    *   DeleteZoneOperationResponse response = zoneOperationsClient.delete(request);
217    * }
218    * }</pre>
219    *
220    * @param request The request object containing all of the parameters for the API call.
221    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
222    */
delete(DeleteZoneOperationRequest request)223   public final DeleteZoneOperationResponse delete(DeleteZoneOperationRequest request) {
224     return deleteCallable().call(request);
225   }
226 
227   // AUTO-GENERATED DOCUMENTATION AND METHOD.
228   /**
229    * Deletes the specified zone-specific Operations resource.
230    *
231    * <p>Sample code:
232    *
233    * <pre>{@code
234    * // This snippet has been automatically generated and should be regarded as a code template only.
235    * // It will require modifications to work:
236    * // - It may require correct/in-range values for request initialization.
237    * // - It may require specifying regional endpoints when creating the service client as shown in
238    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
239    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
240    *   DeleteZoneOperationRequest request =
241    *       DeleteZoneOperationRequest.newBuilder()
242    *           .setOperation("operation1662702951")
243    *           .setProject("project-309310695")
244    *           .setZone("zone3744684")
245    *           .build();
246    *   ApiFuture<DeleteZoneOperationResponse> future =
247    *       zoneOperationsClient.deleteCallable().futureCall(request);
248    *   // Do something.
249    *   DeleteZoneOperationResponse response = future.get();
250    * }
251    * }</pre>
252    */
253   public final UnaryCallable<DeleteZoneOperationRequest, DeleteZoneOperationResponse>
deleteCallable()254       deleteCallable() {
255     return stub.deleteCallable();
256   }
257 
258   // AUTO-GENERATED DOCUMENTATION AND METHOD.
259   /**
260    * Retrieves the specified zone-specific Operations resource.
261    *
262    * <p>Sample code:
263    *
264    * <pre>{@code
265    * // This snippet has been automatically generated and should be regarded as a code template only.
266    * // It will require modifications to work:
267    * // - It may require correct/in-range values for request initialization.
268    * // - It may require specifying regional endpoints when creating the service client as shown in
269    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
270    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
271    *   String project = "project-309310695";
272    *   String zone = "zone3744684";
273    *   String operation = "operation1662702951";
274    *   Operation response = zoneOperationsClient.get(project, zone, operation);
275    * }
276    * }</pre>
277    *
278    * @param project Project ID for this request.
279    * @param zone Name of the zone for this request.
280    * @param operation Name of the Operations resource to return.
281    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
282    */
get(String project, String zone, String operation)283   public final Operation get(String project, String zone, String operation) {
284     GetZoneOperationRequest request =
285         GetZoneOperationRequest.newBuilder()
286             .setProject(project)
287             .setZone(zone)
288             .setOperation(operation)
289             .build();
290     return get(request);
291   }
292 
293   // AUTO-GENERATED DOCUMENTATION AND METHOD.
294   /**
295    * Retrieves the specified zone-specific Operations resource.
296    *
297    * <p>Sample code:
298    *
299    * <pre>{@code
300    * // This snippet has been automatically generated and should be regarded as a code template only.
301    * // It will require modifications to work:
302    * // - It may require correct/in-range values for request initialization.
303    * // - It may require specifying regional endpoints when creating the service client as shown in
304    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
305    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
306    *   GetZoneOperationRequest request =
307    *       GetZoneOperationRequest.newBuilder()
308    *           .setOperation("operation1662702951")
309    *           .setProject("project-309310695")
310    *           .setZone("zone3744684")
311    *           .build();
312    *   Operation response = zoneOperationsClient.get(request);
313    * }
314    * }</pre>
315    *
316    * @param request The request object containing all of the parameters for the API call.
317    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
318    */
get(GetZoneOperationRequest request)319   public final Operation get(GetZoneOperationRequest request) {
320     return getCallable().call(request);
321   }
322 
323   // AUTO-GENERATED DOCUMENTATION AND METHOD.
324   /**
325    * Retrieves the specified zone-specific Operations resource.
326    *
327    * <p>Sample code:
328    *
329    * <pre>{@code
330    * // This snippet has been automatically generated and should be regarded as a code template only.
331    * // It will require modifications to work:
332    * // - It may require correct/in-range values for request initialization.
333    * // - It may require specifying regional endpoints when creating the service client as shown in
334    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
335    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
336    *   GetZoneOperationRequest request =
337    *       GetZoneOperationRequest.newBuilder()
338    *           .setOperation("operation1662702951")
339    *           .setProject("project-309310695")
340    *           .setZone("zone3744684")
341    *           .build();
342    *   ApiFuture<Operation> future = zoneOperationsClient.getCallable().futureCall(request);
343    *   // Do something.
344    *   Operation response = future.get();
345    * }
346    * }</pre>
347    */
getCallable()348   public final UnaryCallable<GetZoneOperationRequest, Operation> getCallable() {
349     return stub.getCallable();
350   }
351 
352   // AUTO-GENERATED DOCUMENTATION AND METHOD.
353   /**
354    * Retrieves a list of Operation resources contained within the specified zone.
355    *
356    * <p>Sample code:
357    *
358    * <pre>{@code
359    * // This snippet has been automatically generated and should be regarded as a code template only.
360    * // It will require modifications to work:
361    * // - It may require correct/in-range values for request initialization.
362    * // - It may require specifying regional endpoints when creating the service client as shown in
363    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
364    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
365    *   String project = "project-309310695";
366    *   String zone = "zone3744684";
367    *   for (Operation element : zoneOperationsClient.list(project, zone).iterateAll()) {
368    *     // doThingsWith(element);
369    *   }
370    * }
371    * }</pre>
372    *
373    * @param project Project ID for this request.
374    * @param zone Name of the zone for request.
375    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
376    */
list(String project, String zone)377   public final ListPagedResponse list(String project, String zone) {
378     ListZoneOperationsRequest request =
379         ListZoneOperationsRequest.newBuilder().setProject(project).setZone(zone).build();
380     return list(request);
381   }
382 
383   // AUTO-GENERATED DOCUMENTATION AND METHOD.
384   /**
385    * Retrieves a list of Operation resources contained within the specified zone.
386    *
387    * <p>Sample code:
388    *
389    * <pre>{@code
390    * // This snippet has been automatically generated and should be regarded as a code template only.
391    * // It will require modifications to work:
392    * // - It may require correct/in-range values for request initialization.
393    * // - It may require specifying regional endpoints when creating the service client as shown in
394    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
395    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
396    *   ListZoneOperationsRequest request =
397    *       ListZoneOperationsRequest.newBuilder()
398    *           .setFilter("filter-1274492040")
399    *           .setMaxResults(1128457243)
400    *           .setOrderBy("orderBy-1207110587")
401    *           .setPageToken("pageToken873572522")
402    *           .setProject("project-309310695")
403    *           .setReturnPartialSuccess(true)
404    *           .setZone("zone3744684")
405    *           .build();
406    *   for (Operation element : zoneOperationsClient.list(request).iterateAll()) {
407    *     // doThingsWith(element);
408    *   }
409    * }
410    * }</pre>
411    *
412    * @param request The request object containing all of the parameters for the API call.
413    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
414    */
list(ListZoneOperationsRequest request)415   public final ListPagedResponse list(ListZoneOperationsRequest request) {
416     return listPagedCallable().call(request);
417   }
418 
419   // AUTO-GENERATED DOCUMENTATION AND METHOD.
420   /**
421    * Retrieves a list of Operation resources contained within the specified zone.
422    *
423    * <p>Sample code:
424    *
425    * <pre>{@code
426    * // This snippet has been automatically generated and should be regarded as a code template only.
427    * // It will require modifications to work:
428    * // - It may require correct/in-range values for request initialization.
429    * // - It may require specifying regional endpoints when creating the service client as shown in
430    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
431    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
432    *   ListZoneOperationsRequest request =
433    *       ListZoneOperationsRequest.newBuilder()
434    *           .setFilter("filter-1274492040")
435    *           .setMaxResults(1128457243)
436    *           .setOrderBy("orderBy-1207110587")
437    *           .setPageToken("pageToken873572522")
438    *           .setProject("project-309310695")
439    *           .setReturnPartialSuccess(true)
440    *           .setZone("zone3744684")
441    *           .build();
442    *   ApiFuture<Operation> future = zoneOperationsClient.listPagedCallable().futureCall(request);
443    *   // Do something.
444    *   for (Operation element : future.get().iterateAll()) {
445    *     // doThingsWith(element);
446    *   }
447    * }
448    * }</pre>
449    */
listPagedCallable()450   public final UnaryCallable<ListZoneOperationsRequest, ListPagedResponse> listPagedCallable() {
451     return stub.listPagedCallable();
452   }
453 
454   // AUTO-GENERATED DOCUMENTATION AND METHOD.
455   /**
456    * Retrieves a list of Operation resources contained within the specified zone.
457    *
458    * <p>Sample code:
459    *
460    * <pre>{@code
461    * // This snippet has been automatically generated and should be regarded as a code template only.
462    * // It will require modifications to work:
463    * // - It may require correct/in-range values for request initialization.
464    * // - It may require specifying regional endpoints when creating the service client as shown in
465    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
466    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
467    *   ListZoneOperationsRequest request =
468    *       ListZoneOperationsRequest.newBuilder()
469    *           .setFilter("filter-1274492040")
470    *           .setMaxResults(1128457243)
471    *           .setOrderBy("orderBy-1207110587")
472    *           .setPageToken("pageToken873572522")
473    *           .setProject("project-309310695")
474    *           .setReturnPartialSuccess(true)
475    *           .setZone("zone3744684")
476    *           .build();
477    *   while (true) {
478    *     OperationList response = zoneOperationsClient.listCallable().call(request);
479    *     for (Operation element : response.getItemsList()) {
480    *       // doThingsWith(element);
481    *     }
482    *     String nextPageToken = response.getNextPageToken();
483    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
484    *       request = request.toBuilder().setPageToken(nextPageToken).build();
485    *     } else {
486    *       break;
487    *     }
488    *   }
489    * }
490    * }</pre>
491    */
listCallable()492   public final UnaryCallable<ListZoneOperationsRequest, OperationList> listCallable() {
493     return stub.listCallable();
494   }
495 
496   // AUTO-GENERATED DOCUMENTATION AND METHOD.
497   /**
498    * Waits for the specified Operation resource to return as `DONE` or for the request to approach
499    * the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no
500    * more than the 2 minutes and then returns the current state of the operation, which might be
501    * `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In
502    * uncommon cases, when the server is overloaded, the request might return before the default
503    * deadline is reached, or might return after zero seconds. - If the default deadline is reached,
504    * there is no guarantee that the operation is actually done when the method returns. Be prepared
505    * to retry if the operation is not `DONE`.
506    *
507    * <p>Sample code:
508    *
509    * <pre>{@code
510    * // This snippet has been automatically generated and should be regarded as a code template only.
511    * // It will require modifications to work:
512    * // - It may require correct/in-range values for request initialization.
513    * // - It may require specifying regional endpoints when creating the service client as shown in
514    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
515    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
516    *   String project = "project-309310695";
517    *   String zone = "zone3744684";
518    *   String operation = "operation1662702951";
519    *   Operation response = zoneOperationsClient.wait(project, zone, operation);
520    * }
521    * }</pre>
522    *
523    * @param project Project ID for this request.
524    * @param zone Name of the zone for this request.
525    * @param operation Name of the Operations resource to return.
526    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
527    */
wait(String project, String zone, String operation)528   public final Operation wait(String project, String zone, String operation) {
529     WaitZoneOperationRequest request =
530         WaitZoneOperationRequest.newBuilder()
531             .setProject(project)
532             .setZone(zone)
533             .setOperation(operation)
534             .build();
535     return wait(request);
536   }
537 
538   // AUTO-GENERATED DOCUMENTATION AND METHOD.
539   /**
540    * Waits for the specified Operation resource to return as `DONE` or for the request to approach
541    * the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no
542    * more than the 2 minutes and then returns the current state of the operation, which might be
543    * `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In
544    * uncommon cases, when the server is overloaded, the request might return before the default
545    * deadline is reached, or might return after zero seconds. - If the default deadline is reached,
546    * there is no guarantee that the operation is actually done when the method returns. Be prepared
547    * to retry if the operation is not `DONE`.
548    *
549    * <p>Sample code:
550    *
551    * <pre>{@code
552    * // This snippet has been automatically generated and should be regarded as a code template only.
553    * // It will require modifications to work:
554    * // - It may require correct/in-range values for request initialization.
555    * // - It may require specifying regional endpoints when creating the service client as shown in
556    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
557    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
558    *   WaitZoneOperationRequest request =
559    *       WaitZoneOperationRequest.newBuilder()
560    *           .setOperation("operation1662702951")
561    *           .setProject("project-309310695")
562    *           .setZone("zone3744684")
563    *           .build();
564    *   Operation response = zoneOperationsClient.wait(request);
565    * }
566    * }</pre>
567    *
568    * @param request The request object containing all of the parameters for the API call.
569    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
570    */
wait(WaitZoneOperationRequest request)571   public final Operation wait(WaitZoneOperationRequest request) {
572     return waitCallable().call(request);
573   }
574 
575   // AUTO-GENERATED DOCUMENTATION AND METHOD.
576   /**
577    * Waits for the specified Operation resource to return as `DONE` or for the request to approach
578    * the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no
579    * more than the 2 minutes and then returns the current state of the operation, which might be
580    * `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In
581    * uncommon cases, when the server is overloaded, the request might return before the default
582    * deadline is reached, or might return after zero seconds. - If the default deadline is reached,
583    * there is no guarantee that the operation is actually done when the method returns. Be prepared
584    * to retry if the operation is not `DONE`.
585    *
586    * <p>Sample code:
587    *
588    * <pre>{@code
589    * // This snippet has been automatically generated and should be regarded as a code template only.
590    * // It will require modifications to work:
591    * // - It may require correct/in-range values for request initialization.
592    * // - It may require specifying regional endpoints when creating the service client as shown in
593    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
594    * try (ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.create()) {
595    *   WaitZoneOperationRequest request =
596    *       WaitZoneOperationRequest.newBuilder()
597    *           .setOperation("operation1662702951")
598    *           .setProject("project-309310695")
599    *           .setZone("zone3744684")
600    *           .build();
601    *   ApiFuture<Operation> future = zoneOperationsClient.waitCallable().futureCall(request);
602    *   // Do something.
603    *   Operation response = future.get();
604    * }
605    * }</pre>
606    */
waitCallable()607   public final UnaryCallable<WaitZoneOperationRequest, Operation> waitCallable() {
608     return stub.waitCallable();
609   }
610 
611   @Override
close()612   public final void close() {
613     stub.close();
614   }
615 
616   @Override
shutdown()617   public void shutdown() {
618     stub.shutdown();
619   }
620 
621   @Override
isShutdown()622   public boolean isShutdown() {
623     return stub.isShutdown();
624   }
625 
626   @Override
isTerminated()627   public boolean isTerminated() {
628     return stub.isTerminated();
629   }
630 
631   @Override
shutdownNow()632   public void shutdownNow() {
633     stub.shutdownNow();
634   }
635 
636   @Override
awaitTermination(long duration, TimeUnit unit)637   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
638     return stub.awaitTermination(duration, unit);
639   }
640 
641   public static class ListPagedResponse
642       extends AbstractPagedListResponse<
643           ListZoneOperationsRequest, OperationList, Operation, ListPage, ListFixedSizeCollection> {
644 
createAsync( PageContext<ListZoneOperationsRequest, OperationList, Operation> context, ApiFuture<OperationList> futureResponse)645     public static ApiFuture<ListPagedResponse> createAsync(
646         PageContext<ListZoneOperationsRequest, OperationList, Operation> context,
647         ApiFuture<OperationList> futureResponse) {
648       ApiFuture<ListPage> futurePage =
649           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
650       return ApiFutures.transform(
651           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
652     }
653 
ListPagedResponse(ListPage page)654     private ListPagedResponse(ListPage page) {
655       super(page, ListFixedSizeCollection.createEmptyCollection());
656     }
657   }
658 
659   public static class ListPage
660       extends AbstractPage<ListZoneOperationsRequest, OperationList, Operation, ListPage> {
661 
ListPage( PageContext<ListZoneOperationsRequest, OperationList, Operation> context, OperationList response)662     private ListPage(
663         PageContext<ListZoneOperationsRequest, OperationList, Operation> context,
664         OperationList response) {
665       super(context, response);
666     }
667 
createEmptyPage()668     private static ListPage createEmptyPage() {
669       return new ListPage(null, null);
670     }
671 
672     @Override
createPage( PageContext<ListZoneOperationsRequest, OperationList, Operation> context, OperationList response)673     protected ListPage createPage(
674         PageContext<ListZoneOperationsRequest, OperationList, Operation> context,
675         OperationList response) {
676       return new ListPage(context, response);
677     }
678 
679     @Override
createPageAsync( PageContext<ListZoneOperationsRequest, OperationList, Operation> context, ApiFuture<OperationList> futureResponse)680     public ApiFuture<ListPage> createPageAsync(
681         PageContext<ListZoneOperationsRequest, OperationList, Operation> context,
682         ApiFuture<OperationList> futureResponse) {
683       return super.createPageAsync(context, futureResponse);
684     }
685   }
686 
687   public static class ListFixedSizeCollection
688       extends AbstractFixedSizeCollection<
689           ListZoneOperationsRequest, OperationList, Operation, ListPage, ListFixedSizeCollection> {
690 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)691     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
692       super(pages, collectionSize);
693     }
694 
createEmptyCollection()695     private static ListFixedSizeCollection createEmptyCollection() {
696       return new ListFixedSizeCollection(null, 0);
697     }
698 
699     @Override
createCollection(List<ListPage> pages, int collectionSize)700     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
701       return new ListFixedSizeCollection(pages, collectionSize);
702     }
703   }
704 }
705