• 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.core.BetaApi;
22 import com.google.api.gax.core.BackgroundResource;
23 import com.google.api.gax.longrunning.OperationFuture;
24 import com.google.api.gax.paging.AbstractFixedSizeCollection;
25 import com.google.api.gax.paging.AbstractPage;
26 import com.google.api.gax.paging.AbstractPagedListResponse;
27 import com.google.api.gax.rpc.OperationCallable;
28 import com.google.api.gax.rpc.PageContext;
29 import com.google.api.gax.rpc.UnaryCallable;
30 import com.google.cloud.compute.v1.stub.ReservationsStub;
31 import com.google.cloud.compute.v1.stub.ReservationsStubSettings;
32 import com.google.common.util.concurrent.MoreExecutors;
33 import java.io.IOException;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.concurrent.TimeUnit;
37 import javax.annotation.Generated;
38 
39 // AUTO-GENERATED DOCUMENTATION AND CLASS.
40 /**
41  * Service Description: The Reservations API.
42  *
43  * <p>This class provides the ability to make remote calls to the backing service through method
44  * calls that map to API methods. Sample code to get started:
45  *
46  * <pre>{@code
47  * // This snippet has been automatically generated and should be regarded as a code template only.
48  * // It will require modifications to work:
49  * // - It may require correct/in-range values for request initialization.
50  * // - It may require specifying regional endpoints when creating the service client as shown in
51  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
52  * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
53  *   String project = "project-309310695";
54  *   String zone = "zone3744684";
55  *   String reservation = "reservation-1563081780";
56  *   Reservation response = reservationsClient.get(project, zone, reservation);
57  * }
58  * }</pre>
59  *
60  * <p>Note: close() needs to be called on the ReservationsClient object to clean up resources such
61  * as threads. In the example above, try-with-resources is used, which automatically calls close().
62  *
63  * <p>The surface of this class includes several types of Java methods for each of the API's
64  * methods:
65  *
66  * <ol>
67  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
68  *       converted into function parameters. It may be the case that not all fields are available as
69  *       parameters, and not every API method will have a flattened method entry point.
70  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
71  *       which must be constructed before the call. Not every API method will have a request object
72  *       method.
73  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
74  *       callable object, which can be used to initiate calls to the service.
75  * </ol>
76  *
77  * <p>See the individual methods for example code.
78  *
79  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
80  * these names, this class includes a format method for each type of name, and additionally a parse
81  * method to extract the individual identifiers contained within names that are returned.
82  *
83  * <p>This class can be customized by passing in a custom instance of ReservationsSettings to
84  * create(). For example:
85  *
86  * <p>To customize credentials:
87  *
88  * <pre>{@code
89  * // This snippet has been automatically generated and should be regarded as a code template only.
90  * // It will require modifications to work:
91  * // - It may require correct/in-range values for request initialization.
92  * // - It may require specifying regional endpoints when creating the service client as shown in
93  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
94  * ReservationsSettings reservationsSettings =
95  *     ReservationsSettings.newBuilder()
96  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
97  *         .build();
98  * ReservationsClient reservationsClient = ReservationsClient.create(reservationsSettings);
99  * }</pre>
100  *
101  * <p>To customize the endpoint:
102  *
103  * <pre>{@code
104  * // This snippet has been automatically generated and should be regarded as a code template only.
105  * // It will require modifications to work:
106  * // - It may require correct/in-range values for request initialization.
107  * // - It may require specifying regional endpoints when creating the service client as shown in
108  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
109  * ReservationsSettings reservationsSettings =
110  *     ReservationsSettings.newBuilder().setEndpoint(myEndpoint).build();
111  * ReservationsClient reservationsClient = ReservationsClient.create(reservationsSettings);
112  * }</pre>
113  *
114  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
115  */
116 @Generated("by gapic-generator-java")
117 public class ReservationsClient implements BackgroundResource {
118   private final ReservationsSettings settings;
119   private final ReservationsStub stub;
120 
121   /** Constructs an instance of ReservationsClient with default settings. */
create()122   public static final ReservationsClient create() throws IOException {
123     return create(ReservationsSettings.newBuilder().build());
124   }
125 
126   /**
127    * Constructs an instance of ReservationsClient, using the given settings. The channels are
128    * created based on the settings passed in, or defaults for any settings that are not set.
129    */
create(ReservationsSettings settings)130   public static final ReservationsClient create(ReservationsSettings settings) throws IOException {
131     return new ReservationsClient(settings);
132   }
133 
134   /**
135    * Constructs an instance of ReservationsClient, using the given stub for making calls. This is
136    * for advanced usage - prefer using create(ReservationsSettings).
137    */
create(ReservationsStub stub)138   public static final ReservationsClient create(ReservationsStub stub) {
139     return new ReservationsClient(stub);
140   }
141 
142   /**
143    * Constructs an instance of ReservationsClient, using the given settings. This is protected so
144    * that it is easy to make a subclass, but otherwise, the static factory methods should be
145    * preferred.
146    */
ReservationsClient(ReservationsSettings settings)147   protected ReservationsClient(ReservationsSettings settings) throws IOException {
148     this.settings = settings;
149     this.stub = ((ReservationsStubSettings) settings.getStubSettings()).createStub();
150   }
151 
ReservationsClient(ReservationsStub stub)152   protected ReservationsClient(ReservationsStub stub) {
153     this.settings = null;
154     this.stub = stub;
155   }
156 
getSettings()157   public final ReservationsSettings getSettings() {
158     return settings;
159   }
160 
getStub()161   public ReservationsStub getStub() {
162     return stub;
163   }
164 
165   // AUTO-GENERATED DOCUMENTATION AND METHOD.
166   /**
167    * Retrieves an aggregated list of reservations.
168    *
169    * <p>Sample code:
170    *
171    * <pre>{@code
172    * // This snippet has been automatically generated and should be regarded as a code template only.
173    * // It will require modifications to work:
174    * // - It may require correct/in-range values for request initialization.
175    * // - It may require specifying regional endpoints when creating the service client as shown in
176    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
177    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
178    *   String project = "project-309310695";
179    *   for (Map.Entry<String, ReservationsScopedList> element :
180    *       reservationsClient.aggregatedList(project).iterateAll()) {
181    *     // doThingsWith(element);
182    *   }
183    * }
184    * }</pre>
185    *
186    * @param project Project ID for this request.
187    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
188    */
aggregatedList(String project)189   public final AggregatedListPagedResponse aggregatedList(String project) {
190     AggregatedListReservationsRequest request =
191         AggregatedListReservationsRequest.newBuilder().setProject(project).build();
192     return aggregatedList(request);
193   }
194 
195   // AUTO-GENERATED DOCUMENTATION AND METHOD.
196   /**
197    * Retrieves an aggregated list of reservations.
198    *
199    * <p>Sample code:
200    *
201    * <pre>{@code
202    * // This snippet has been automatically generated and should be regarded as a code template only.
203    * // It will require modifications to work:
204    * // - It may require correct/in-range values for request initialization.
205    * // - It may require specifying regional endpoints when creating the service client as shown in
206    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
207    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
208    *   AggregatedListReservationsRequest request =
209    *       AggregatedListReservationsRequest.newBuilder()
210    *           .setFilter("filter-1274492040")
211    *           .setIncludeAllScopes(true)
212    *           .setMaxResults(1128457243)
213    *           .setOrderBy("orderBy-1207110587")
214    *           .setPageToken("pageToken873572522")
215    *           .setProject("project-309310695")
216    *           .setReturnPartialSuccess(true)
217    *           .build();
218    *   for (Map.Entry<String, ReservationsScopedList> element :
219    *       reservationsClient.aggregatedList(request).iterateAll()) {
220    *     // doThingsWith(element);
221    *   }
222    * }
223    * }</pre>
224    *
225    * @param request The request object containing all of the parameters for the API call.
226    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
227    */
aggregatedList( AggregatedListReservationsRequest request)228   public final AggregatedListPagedResponse aggregatedList(
229       AggregatedListReservationsRequest request) {
230     return aggregatedListPagedCallable().call(request);
231   }
232 
233   // AUTO-GENERATED DOCUMENTATION AND METHOD.
234   /**
235    * Retrieves an aggregated list of reservations.
236    *
237    * <p>Sample code:
238    *
239    * <pre>{@code
240    * // This snippet has been automatically generated and should be regarded as a code template only.
241    * // It will require modifications to work:
242    * // - It may require correct/in-range values for request initialization.
243    * // - It may require specifying regional endpoints when creating the service client as shown in
244    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
245    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
246    *   AggregatedListReservationsRequest request =
247    *       AggregatedListReservationsRequest.newBuilder()
248    *           .setFilter("filter-1274492040")
249    *           .setIncludeAllScopes(true)
250    *           .setMaxResults(1128457243)
251    *           .setOrderBy("orderBy-1207110587")
252    *           .setPageToken("pageToken873572522")
253    *           .setProject("project-309310695")
254    *           .setReturnPartialSuccess(true)
255    *           .build();
256    *   ApiFuture<Map.Entry<String, ReservationsScopedList>> future =
257    *       reservationsClient.aggregatedListPagedCallable().futureCall(request);
258    *   // Do something.
259    *   for (Map.Entry<String, ReservationsScopedList> element : future.get().iterateAll()) {
260    *     // doThingsWith(element);
261    *   }
262    * }
263    * }</pre>
264    */
265   public final UnaryCallable<AggregatedListReservationsRequest, AggregatedListPagedResponse>
aggregatedListPagedCallable()266       aggregatedListPagedCallable() {
267     return stub.aggregatedListPagedCallable();
268   }
269 
270   // AUTO-GENERATED DOCUMENTATION AND METHOD.
271   /**
272    * Retrieves an aggregated list of reservations.
273    *
274    * <p>Sample code:
275    *
276    * <pre>{@code
277    * // This snippet has been automatically generated and should be regarded as a code template only.
278    * // It will require modifications to work:
279    * // - It may require correct/in-range values for request initialization.
280    * // - It may require specifying regional endpoints when creating the service client as shown in
281    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
282    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
283    *   AggregatedListReservationsRequest request =
284    *       AggregatedListReservationsRequest.newBuilder()
285    *           .setFilter("filter-1274492040")
286    *           .setIncludeAllScopes(true)
287    *           .setMaxResults(1128457243)
288    *           .setOrderBy("orderBy-1207110587")
289    *           .setPageToken("pageToken873572522")
290    *           .setProject("project-309310695")
291    *           .setReturnPartialSuccess(true)
292    *           .build();
293    *   while (true) {
294    *     ReservationAggregatedList response =
295    *         reservationsClient.aggregatedListCallable().call(request);
296    *     for (Map.Entry<String, ReservationsScopedList> element : response.getItemsList()) {
297    *       // doThingsWith(element);
298    *     }
299    *     String nextPageToken = response.getNextPageToken();
300    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
301    *       request = request.toBuilder().setPageToken(nextPageToken).build();
302    *     } else {
303    *       break;
304    *     }
305    *   }
306    * }
307    * }</pre>
308    */
309   public final UnaryCallable<AggregatedListReservationsRequest, ReservationAggregatedList>
aggregatedListCallable()310       aggregatedListCallable() {
311     return stub.aggregatedListCallable();
312   }
313 
314   // AUTO-GENERATED DOCUMENTATION AND METHOD.
315   /**
316    * Deletes the specified reservation.
317    *
318    * <p>Sample code:
319    *
320    * <pre>{@code
321    * // This snippet has been automatically generated and should be regarded as a code template only.
322    * // It will require modifications to work:
323    * // - It may require correct/in-range values for request initialization.
324    * // - It may require specifying regional endpoints when creating the service client as shown in
325    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
326    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
327    *   String project = "project-309310695";
328    *   String zone = "zone3744684";
329    *   String reservation = "reservation-1563081780";
330    *   Operation response = reservationsClient.deleteAsync(project, zone, reservation).get();
331    * }
332    * }</pre>
333    *
334    * @param project Project ID for this request.
335    * @param zone Name of the zone for this request.
336    * @param reservation Name of the reservation to delete.
337    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
338    */
deleteAsync( String project, String zone, String reservation)339   public final OperationFuture<Operation, Operation> deleteAsync(
340       String project, String zone, String reservation) {
341     DeleteReservationRequest request =
342         DeleteReservationRequest.newBuilder()
343             .setProject(project)
344             .setZone(zone)
345             .setReservation(reservation)
346             .build();
347     return deleteAsync(request);
348   }
349 
350   // AUTO-GENERATED DOCUMENTATION AND METHOD.
351   /**
352    * Deletes the specified reservation.
353    *
354    * <p>Sample code:
355    *
356    * <pre>{@code
357    * // This snippet has been automatically generated and should be regarded as a code template only.
358    * // It will require modifications to work:
359    * // - It may require correct/in-range values for request initialization.
360    * // - It may require specifying regional endpoints when creating the service client as shown in
361    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
362    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
363    *   DeleteReservationRequest request =
364    *       DeleteReservationRequest.newBuilder()
365    *           .setProject("project-309310695")
366    *           .setRequestId("requestId693933066")
367    *           .setReservation("reservation-1563081780")
368    *           .setZone("zone3744684")
369    *           .build();
370    *   Operation response = reservationsClient.deleteAsync(request).get();
371    * }
372    * }</pre>
373    *
374    * @param request The request object containing all of the parameters for the API call.
375    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
376    */
377   @BetaApi(
378       "The surface for long-running operations is not stable yet and may change in the future.")
deleteAsync(DeleteReservationRequest request)379   public final OperationFuture<Operation, Operation> deleteAsync(DeleteReservationRequest request) {
380     return deleteOperationCallable().futureCall(request);
381   }
382 
383   // AUTO-GENERATED DOCUMENTATION AND METHOD.
384   /**
385    * Deletes the specified reservation.
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 (ReservationsClient reservationsClient = ReservationsClient.create()) {
396    *   DeleteReservationRequest request =
397    *       DeleteReservationRequest.newBuilder()
398    *           .setProject("project-309310695")
399    *           .setRequestId("requestId693933066")
400    *           .setReservation("reservation-1563081780")
401    *           .setZone("zone3744684")
402    *           .build();
403    *   OperationFuture<Operation, Operation> future =
404    *       reservationsClient.deleteOperationCallable().futureCall(request);
405    *   // Do something.
406    *   Operation response = future.get();
407    * }
408    * }</pre>
409    */
410   public final OperationCallable<DeleteReservationRequest, Operation, Operation>
deleteOperationCallable()411       deleteOperationCallable() {
412     return stub.deleteOperationCallable();
413   }
414 
415   // AUTO-GENERATED DOCUMENTATION AND METHOD.
416   /**
417    * Deletes the specified reservation.
418    *
419    * <p>Sample code:
420    *
421    * <pre>{@code
422    * // This snippet has been automatically generated and should be regarded as a code template only.
423    * // It will require modifications to work:
424    * // - It may require correct/in-range values for request initialization.
425    * // - It may require specifying regional endpoints when creating the service client as shown in
426    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
427    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
428    *   DeleteReservationRequest request =
429    *       DeleteReservationRequest.newBuilder()
430    *           .setProject("project-309310695")
431    *           .setRequestId("requestId693933066")
432    *           .setReservation("reservation-1563081780")
433    *           .setZone("zone3744684")
434    *           .build();
435    *   ApiFuture<Operation> future = reservationsClient.deleteCallable().futureCall(request);
436    *   // Do something.
437    *   Operation response = future.get();
438    * }
439    * }</pre>
440    */
deleteCallable()441   public final UnaryCallable<DeleteReservationRequest, Operation> deleteCallable() {
442     return stub.deleteCallable();
443   }
444 
445   // AUTO-GENERATED DOCUMENTATION AND METHOD.
446   /**
447    * Retrieves information about the specified reservation.
448    *
449    * <p>Sample code:
450    *
451    * <pre>{@code
452    * // This snippet has been automatically generated and should be regarded as a code template only.
453    * // It will require modifications to work:
454    * // - It may require correct/in-range values for request initialization.
455    * // - It may require specifying regional endpoints when creating the service client as shown in
456    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
457    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
458    *   String project = "project-309310695";
459    *   String zone = "zone3744684";
460    *   String reservation = "reservation-1563081780";
461    *   Reservation response = reservationsClient.get(project, zone, reservation);
462    * }
463    * }</pre>
464    *
465    * @param project Project ID for this request.
466    * @param zone Name of the zone for this request.
467    * @param reservation Name of the reservation to retrieve.
468    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
469    */
get(String project, String zone, String reservation)470   public final Reservation get(String project, String zone, String reservation) {
471     GetReservationRequest request =
472         GetReservationRequest.newBuilder()
473             .setProject(project)
474             .setZone(zone)
475             .setReservation(reservation)
476             .build();
477     return get(request);
478   }
479 
480   // AUTO-GENERATED DOCUMENTATION AND METHOD.
481   /**
482    * Retrieves information about the specified reservation.
483    *
484    * <p>Sample code:
485    *
486    * <pre>{@code
487    * // This snippet has been automatically generated and should be regarded as a code template only.
488    * // It will require modifications to work:
489    * // - It may require correct/in-range values for request initialization.
490    * // - It may require specifying regional endpoints when creating the service client as shown in
491    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
492    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
493    *   GetReservationRequest request =
494    *       GetReservationRequest.newBuilder()
495    *           .setProject("project-309310695")
496    *           .setReservation("reservation-1563081780")
497    *           .setZone("zone3744684")
498    *           .build();
499    *   Reservation response = reservationsClient.get(request);
500    * }
501    * }</pre>
502    *
503    * @param request The request object containing all of the parameters for the API call.
504    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
505    */
get(GetReservationRequest request)506   public final Reservation get(GetReservationRequest request) {
507     return getCallable().call(request);
508   }
509 
510   // AUTO-GENERATED DOCUMENTATION AND METHOD.
511   /**
512    * Retrieves information about the specified reservation.
513    *
514    * <p>Sample code:
515    *
516    * <pre>{@code
517    * // This snippet has been automatically generated and should be regarded as a code template only.
518    * // It will require modifications to work:
519    * // - It may require correct/in-range values for request initialization.
520    * // - It may require specifying regional endpoints when creating the service client as shown in
521    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
522    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
523    *   GetReservationRequest request =
524    *       GetReservationRequest.newBuilder()
525    *           .setProject("project-309310695")
526    *           .setReservation("reservation-1563081780")
527    *           .setZone("zone3744684")
528    *           .build();
529    *   ApiFuture<Reservation> future = reservationsClient.getCallable().futureCall(request);
530    *   // Do something.
531    *   Reservation response = future.get();
532    * }
533    * }</pre>
534    */
getCallable()535   public final UnaryCallable<GetReservationRequest, Reservation> getCallable() {
536     return stub.getCallable();
537   }
538 
539   // AUTO-GENERATED DOCUMENTATION AND METHOD.
540   /**
541    * Gets the access control policy for a resource. May be empty if no such policy or resource
542    * exists.
543    *
544    * <p>Sample code:
545    *
546    * <pre>{@code
547    * // This snippet has been automatically generated and should be regarded as a code template only.
548    * // It will require modifications to work:
549    * // - It may require correct/in-range values for request initialization.
550    * // - It may require specifying regional endpoints when creating the service client as shown in
551    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
552    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
553    *   String project = "project-309310695";
554    *   String zone = "zone3744684";
555    *   String resource = "resource-341064690";
556    *   Policy response = reservationsClient.getIamPolicy(project, zone, resource);
557    * }
558    * }</pre>
559    *
560    * @param project Project ID for this request.
561    * @param zone The name of the zone for this request.
562    * @param resource Name or id of the resource for this request.
563    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
564    */
getIamPolicy(String project, String zone, String resource)565   public final Policy getIamPolicy(String project, String zone, String resource) {
566     GetIamPolicyReservationRequest request =
567         GetIamPolicyReservationRequest.newBuilder()
568             .setProject(project)
569             .setZone(zone)
570             .setResource(resource)
571             .build();
572     return getIamPolicy(request);
573   }
574 
575   // AUTO-GENERATED DOCUMENTATION AND METHOD.
576   /**
577    * Gets the access control policy for a resource. May be empty if no such policy or resource
578    * exists.
579    *
580    * <p>Sample code:
581    *
582    * <pre>{@code
583    * // This snippet has been automatically generated and should be regarded as a code template only.
584    * // It will require modifications to work:
585    * // - It may require correct/in-range values for request initialization.
586    * // - It may require specifying regional endpoints when creating the service client as shown in
587    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
588    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
589    *   GetIamPolicyReservationRequest request =
590    *       GetIamPolicyReservationRequest.newBuilder()
591    *           .setOptionsRequestedPolicyVersion(-574521795)
592    *           .setProject("project-309310695")
593    *           .setResource("resource-341064690")
594    *           .setZone("zone3744684")
595    *           .build();
596    *   Policy response = reservationsClient.getIamPolicy(request);
597    * }
598    * }</pre>
599    *
600    * @param request The request object containing all of the parameters for the API call.
601    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
602    */
getIamPolicy(GetIamPolicyReservationRequest request)603   public final Policy getIamPolicy(GetIamPolicyReservationRequest request) {
604     return getIamPolicyCallable().call(request);
605   }
606 
607   // AUTO-GENERATED DOCUMENTATION AND METHOD.
608   /**
609    * Gets the access control policy for a resource. May be empty if no such policy or resource
610    * exists.
611    *
612    * <p>Sample code:
613    *
614    * <pre>{@code
615    * // This snippet has been automatically generated and should be regarded as a code template only.
616    * // It will require modifications to work:
617    * // - It may require correct/in-range values for request initialization.
618    * // - It may require specifying regional endpoints when creating the service client as shown in
619    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
620    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
621    *   GetIamPolicyReservationRequest request =
622    *       GetIamPolicyReservationRequest.newBuilder()
623    *           .setOptionsRequestedPolicyVersion(-574521795)
624    *           .setProject("project-309310695")
625    *           .setResource("resource-341064690")
626    *           .setZone("zone3744684")
627    *           .build();
628    *   ApiFuture<Policy> future = reservationsClient.getIamPolicyCallable().futureCall(request);
629    *   // Do something.
630    *   Policy response = future.get();
631    * }
632    * }</pre>
633    */
getIamPolicyCallable()634   public final UnaryCallable<GetIamPolicyReservationRequest, Policy> getIamPolicyCallable() {
635     return stub.getIamPolicyCallable();
636   }
637 
638   // AUTO-GENERATED DOCUMENTATION AND METHOD.
639   /**
640    * Creates a new reservation. For more information, read Reserving zonal resources.
641    *
642    * <p>Sample code:
643    *
644    * <pre>{@code
645    * // This snippet has been automatically generated and should be regarded as a code template only.
646    * // It will require modifications to work:
647    * // - It may require correct/in-range values for request initialization.
648    * // - It may require specifying regional endpoints when creating the service client as shown in
649    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
650    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
651    *   String project = "project-309310695";
652    *   String zone = "zone3744684";
653    *   Reservation reservationResource = Reservation.newBuilder().build();
654    *   Operation response = reservationsClient.insertAsync(project, zone, reservationResource).get();
655    * }
656    * }</pre>
657    *
658    * @param project Project ID for this request.
659    * @param zone Name of the zone for this request.
660    * @param reservationResource The body resource for this request
661    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
662    */
insertAsync( String project, String zone, Reservation reservationResource)663   public final OperationFuture<Operation, Operation> insertAsync(
664       String project, String zone, Reservation reservationResource) {
665     InsertReservationRequest request =
666         InsertReservationRequest.newBuilder()
667             .setProject(project)
668             .setZone(zone)
669             .setReservationResource(reservationResource)
670             .build();
671     return insertAsync(request);
672   }
673 
674   // AUTO-GENERATED DOCUMENTATION AND METHOD.
675   /**
676    * Creates a new reservation. For more information, read Reserving zonal resources.
677    *
678    * <p>Sample code:
679    *
680    * <pre>{@code
681    * // This snippet has been automatically generated and should be regarded as a code template only.
682    * // It will require modifications to work:
683    * // - It may require correct/in-range values for request initialization.
684    * // - It may require specifying regional endpoints when creating the service client as shown in
685    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
686    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
687    *   InsertReservationRequest request =
688    *       InsertReservationRequest.newBuilder()
689    *           .setProject("project-309310695")
690    *           .setRequestId("requestId693933066")
691    *           .setReservationResource(Reservation.newBuilder().build())
692    *           .setZone("zone3744684")
693    *           .build();
694    *   Operation response = reservationsClient.insertAsync(request).get();
695    * }
696    * }</pre>
697    *
698    * @param request The request object containing all of the parameters for the API call.
699    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
700    */
701   @BetaApi(
702       "The surface for long-running operations is not stable yet and may change in the future.")
insertAsync(InsertReservationRequest request)703   public final OperationFuture<Operation, Operation> insertAsync(InsertReservationRequest request) {
704     return insertOperationCallable().futureCall(request);
705   }
706 
707   // AUTO-GENERATED DOCUMENTATION AND METHOD.
708   /**
709    * Creates a new reservation. For more information, read Reserving zonal resources.
710    *
711    * <p>Sample code:
712    *
713    * <pre>{@code
714    * // This snippet has been automatically generated and should be regarded as a code template only.
715    * // It will require modifications to work:
716    * // - It may require correct/in-range values for request initialization.
717    * // - It may require specifying regional endpoints when creating the service client as shown in
718    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
719    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
720    *   InsertReservationRequest request =
721    *       InsertReservationRequest.newBuilder()
722    *           .setProject("project-309310695")
723    *           .setRequestId("requestId693933066")
724    *           .setReservationResource(Reservation.newBuilder().build())
725    *           .setZone("zone3744684")
726    *           .build();
727    *   OperationFuture<Operation, Operation> future =
728    *       reservationsClient.insertOperationCallable().futureCall(request);
729    *   // Do something.
730    *   Operation response = future.get();
731    * }
732    * }</pre>
733    */
734   public final OperationCallable<InsertReservationRequest, Operation, Operation>
insertOperationCallable()735       insertOperationCallable() {
736     return stub.insertOperationCallable();
737   }
738 
739   // AUTO-GENERATED DOCUMENTATION AND METHOD.
740   /**
741    * Creates a new reservation. For more information, read Reserving zonal resources.
742    *
743    * <p>Sample code:
744    *
745    * <pre>{@code
746    * // This snippet has been automatically generated and should be regarded as a code template only.
747    * // It will require modifications to work:
748    * // - It may require correct/in-range values for request initialization.
749    * // - It may require specifying regional endpoints when creating the service client as shown in
750    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
751    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
752    *   InsertReservationRequest request =
753    *       InsertReservationRequest.newBuilder()
754    *           .setProject("project-309310695")
755    *           .setRequestId("requestId693933066")
756    *           .setReservationResource(Reservation.newBuilder().build())
757    *           .setZone("zone3744684")
758    *           .build();
759    *   ApiFuture<Operation> future = reservationsClient.insertCallable().futureCall(request);
760    *   // Do something.
761    *   Operation response = future.get();
762    * }
763    * }</pre>
764    */
insertCallable()765   public final UnaryCallable<InsertReservationRequest, Operation> insertCallable() {
766     return stub.insertCallable();
767   }
768 
769   // AUTO-GENERATED DOCUMENTATION AND METHOD.
770   /**
771    * A list of all the reservations that have been configured for the specified project in specified
772    * zone.
773    *
774    * <p>Sample code:
775    *
776    * <pre>{@code
777    * // This snippet has been automatically generated and should be regarded as a code template only.
778    * // It will require modifications to work:
779    * // - It may require correct/in-range values for request initialization.
780    * // - It may require specifying regional endpoints when creating the service client as shown in
781    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
782    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
783    *   String project = "project-309310695";
784    *   String zone = "zone3744684";
785    *   for (Reservation element : reservationsClient.list(project, zone).iterateAll()) {
786    *     // doThingsWith(element);
787    *   }
788    * }
789    * }</pre>
790    *
791    * @param project Project ID for this request.
792    * @param zone Name of the zone for this request.
793    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
794    */
list(String project, String zone)795   public final ListPagedResponse list(String project, String zone) {
796     ListReservationsRequest request =
797         ListReservationsRequest.newBuilder().setProject(project).setZone(zone).build();
798     return list(request);
799   }
800 
801   // AUTO-GENERATED DOCUMENTATION AND METHOD.
802   /**
803    * A list of all the reservations that have been configured for the specified project in specified
804    * zone.
805    *
806    * <p>Sample code:
807    *
808    * <pre>{@code
809    * // This snippet has been automatically generated and should be regarded as a code template only.
810    * // It will require modifications to work:
811    * // - It may require correct/in-range values for request initialization.
812    * // - It may require specifying regional endpoints when creating the service client as shown in
813    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
814    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
815    *   ListReservationsRequest request =
816    *       ListReservationsRequest.newBuilder()
817    *           .setFilter("filter-1274492040")
818    *           .setMaxResults(1128457243)
819    *           .setOrderBy("orderBy-1207110587")
820    *           .setPageToken("pageToken873572522")
821    *           .setProject("project-309310695")
822    *           .setReturnPartialSuccess(true)
823    *           .setZone("zone3744684")
824    *           .build();
825    *   for (Reservation element : reservationsClient.list(request).iterateAll()) {
826    *     // doThingsWith(element);
827    *   }
828    * }
829    * }</pre>
830    *
831    * @param request The request object containing all of the parameters for the API call.
832    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
833    */
list(ListReservationsRequest request)834   public final ListPagedResponse list(ListReservationsRequest request) {
835     return listPagedCallable().call(request);
836   }
837 
838   // AUTO-GENERATED DOCUMENTATION AND METHOD.
839   /**
840    * A list of all the reservations that have been configured for the specified project in specified
841    * zone.
842    *
843    * <p>Sample code:
844    *
845    * <pre>{@code
846    * // This snippet has been automatically generated and should be regarded as a code template only.
847    * // It will require modifications to work:
848    * // - It may require correct/in-range values for request initialization.
849    * // - It may require specifying regional endpoints when creating the service client as shown in
850    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
851    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
852    *   ListReservationsRequest request =
853    *       ListReservationsRequest.newBuilder()
854    *           .setFilter("filter-1274492040")
855    *           .setMaxResults(1128457243)
856    *           .setOrderBy("orderBy-1207110587")
857    *           .setPageToken("pageToken873572522")
858    *           .setProject("project-309310695")
859    *           .setReturnPartialSuccess(true)
860    *           .setZone("zone3744684")
861    *           .build();
862    *   ApiFuture<Reservation> future = reservationsClient.listPagedCallable().futureCall(request);
863    *   // Do something.
864    *   for (Reservation element : future.get().iterateAll()) {
865    *     // doThingsWith(element);
866    *   }
867    * }
868    * }</pre>
869    */
listPagedCallable()870   public final UnaryCallable<ListReservationsRequest, ListPagedResponse> listPagedCallable() {
871     return stub.listPagedCallable();
872   }
873 
874   // AUTO-GENERATED DOCUMENTATION AND METHOD.
875   /**
876    * A list of all the reservations that have been configured for the specified project in specified
877    * zone.
878    *
879    * <p>Sample code:
880    *
881    * <pre>{@code
882    * // This snippet has been automatically generated and should be regarded as a code template only.
883    * // It will require modifications to work:
884    * // - It may require correct/in-range values for request initialization.
885    * // - It may require specifying regional endpoints when creating the service client as shown in
886    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
887    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
888    *   ListReservationsRequest request =
889    *       ListReservationsRequest.newBuilder()
890    *           .setFilter("filter-1274492040")
891    *           .setMaxResults(1128457243)
892    *           .setOrderBy("orderBy-1207110587")
893    *           .setPageToken("pageToken873572522")
894    *           .setProject("project-309310695")
895    *           .setReturnPartialSuccess(true)
896    *           .setZone("zone3744684")
897    *           .build();
898    *   while (true) {
899    *     ReservationList response = reservationsClient.listCallable().call(request);
900    *     for (Reservation element : response.getItemsList()) {
901    *       // doThingsWith(element);
902    *     }
903    *     String nextPageToken = response.getNextPageToken();
904    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
905    *       request = request.toBuilder().setPageToken(nextPageToken).build();
906    *     } else {
907    *       break;
908    *     }
909    *   }
910    * }
911    * }</pre>
912    */
listCallable()913   public final UnaryCallable<ListReservationsRequest, ReservationList> listCallable() {
914     return stub.listCallable();
915   }
916 
917   // AUTO-GENERATED DOCUMENTATION AND METHOD.
918   /**
919    * Resizes the reservation (applicable to standalone reservations only). For more information,
920    * read Modifying reservations.
921    *
922    * <p>Sample code:
923    *
924    * <pre>{@code
925    * // This snippet has been automatically generated and should be regarded as a code template only.
926    * // It will require modifications to work:
927    * // - It may require correct/in-range values for request initialization.
928    * // - It may require specifying regional endpoints when creating the service client as shown in
929    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
930    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
931    *   String project = "project-309310695";
932    *   String zone = "zone3744684";
933    *   String reservation = "reservation-1563081780";
934    *   ReservationsResizeRequest reservationsResizeRequestResource =
935    *       ReservationsResizeRequest.newBuilder().build();
936    *   Operation response =
937    *       reservationsClient
938    *           .resizeAsync(project, zone, reservation, reservationsResizeRequestResource)
939    *           .get();
940    * }
941    * }</pre>
942    *
943    * @param project Project ID for this request.
944    * @param zone Name of the zone for this request.
945    * @param reservation Name of the reservation to update.
946    * @param reservationsResizeRequestResource The body resource for this request
947    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
948    */
resizeAsync( String project, String zone, String reservation, ReservationsResizeRequest reservationsResizeRequestResource)949   public final OperationFuture<Operation, Operation> resizeAsync(
950       String project,
951       String zone,
952       String reservation,
953       ReservationsResizeRequest reservationsResizeRequestResource) {
954     ResizeReservationRequest request =
955         ResizeReservationRequest.newBuilder()
956             .setProject(project)
957             .setZone(zone)
958             .setReservation(reservation)
959             .setReservationsResizeRequestResource(reservationsResizeRequestResource)
960             .build();
961     return resizeAsync(request);
962   }
963 
964   // AUTO-GENERATED DOCUMENTATION AND METHOD.
965   /**
966    * Resizes the reservation (applicable to standalone reservations only). For more information,
967    * read Modifying reservations.
968    *
969    * <p>Sample code:
970    *
971    * <pre>{@code
972    * // This snippet has been automatically generated and should be regarded as a code template only.
973    * // It will require modifications to work:
974    * // - It may require correct/in-range values for request initialization.
975    * // - It may require specifying regional endpoints when creating the service client as shown in
976    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
977    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
978    *   ResizeReservationRequest request =
979    *       ResizeReservationRequest.newBuilder()
980    *           .setProject("project-309310695")
981    *           .setRequestId("requestId693933066")
982    *           .setReservation("reservation-1563081780")
983    *           .setReservationsResizeRequestResource(ReservationsResizeRequest.newBuilder().build())
984    *           .setZone("zone3744684")
985    *           .build();
986    *   Operation response = reservationsClient.resizeAsync(request).get();
987    * }
988    * }</pre>
989    *
990    * @param request The request object containing all of the parameters for the API call.
991    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
992    */
993   @BetaApi(
994       "The surface for long-running operations is not stable yet and may change in the future.")
resizeAsync(ResizeReservationRequest request)995   public final OperationFuture<Operation, Operation> resizeAsync(ResizeReservationRequest request) {
996     return resizeOperationCallable().futureCall(request);
997   }
998 
999   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1000   /**
1001    * Resizes the reservation (applicable to standalone reservations only). For more information,
1002    * read Modifying reservations.
1003    *
1004    * <p>Sample code:
1005    *
1006    * <pre>{@code
1007    * // This snippet has been automatically generated and should be regarded as a code template only.
1008    * // It will require modifications to work:
1009    * // - It may require correct/in-range values for request initialization.
1010    * // - It may require specifying regional endpoints when creating the service client as shown in
1011    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1012    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1013    *   ResizeReservationRequest request =
1014    *       ResizeReservationRequest.newBuilder()
1015    *           .setProject("project-309310695")
1016    *           .setRequestId("requestId693933066")
1017    *           .setReservation("reservation-1563081780")
1018    *           .setReservationsResizeRequestResource(ReservationsResizeRequest.newBuilder().build())
1019    *           .setZone("zone3744684")
1020    *           .build();
1021    *   OperationFuture<Operation, Operation> future =
1022    *       reservationsClient.resizeOperationCallable().futureCall(request);
1023    *   // Do something.
1024    *   Operation response = future.get();
1025    * }
1026    * }</pre>
1027    */
1028   public final OperationCallable<ResizeReservationRequest, Operation, Operation>
resizeOperationCallable()1029       resizeOperationCallable() {
1030     return stub.resizeOperationCallable();
1031   }
1032 
1033   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1034   /**
1035    * Resizes the reservation (applicable to standalone reservations only). For more information,
1036    * read Modifying reservations.
1037    *
1038    * <p>Sample code:
1039    *
1040    * <pre>{@code
1041    * // This snippet has been automatically generated and should be regarded as a code template only.
1042    * // It will require modifications to work:
1043    * // - It may require correct/in-range values for request initialization.
1044    * // - It may require specifying regional endpoints when creating the service client as shown in
1045    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1046    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1047    *   ResizeReservationRequest request =
1048    *       ResizeReservationRequest.newBuilder()
1049    *           .setProject("project-309310695")
1050    *           .setRequestId("requestId693933066")
1051    *           .setReservation("reservation-1563081780")
1052    *           .setReservationsResizeRequestResource(ReservationsResizeRequest.newBuilder().build())
1053    *           .setZone("zone3744684")
1054    *           .build();
1055    *   ApiFuture<Operation> future = reservationsClient.resizeCallable().futureCall(request);
1056    *   // Do something.
1057    *   Operation response = future.get();
1058    * }
1059    * }</pre>
1060    */
resizeCallable()1061   public final UnaryCallable<ResizeReservationRequest, Operation> resizeCallable() {
1062     return stub.resizeCallable();
1063   }
1064 
1065   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1066   /**
1067    * Sets the access control policy on the specified resource. Replaces any existing policy.
1068    *
1069    * <p>Sample code:
1070    *
1071    * <pre>{@code
1072    * // This snippet has been automatically generated and should be regarded as a code template only.
1073    * // It will require modifications to work:
1074    * // - It may require correct/in-range values for request initialization.
1075    * // - It may require specifying regional endpoints when creating the service client as shown in
1076    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1077    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1078    *   String project = "project-309310695";
1079    *   String zone = "zone3744684";
1080    *   String resource = "resource-341064690";
1081    *   ZoneSetPolicyRequest zoneSetPolicyRequestResource = ZoneSetPolicyRequest.newBuilder().build();
1082    *   Policy response =
1083    *       reservationsClient.setIamPolicy(project, zone, resource, zoneSetPolicyRequestResource);
1084    * }
1085    * }</pre>
1086    *
1087    * @param project Project ID for this request.
1088    * @param zone The name of the zone for this request.
1089    * @param resource Name or id of the resource for this request.
1090    * @param zoneSetPolicyRequestResource The body resource for this request
1091    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1092    */
setIamPolicy( String project, String zone, String resource, ZoneSetPolicyRequest zoneSetPolicyRequestResource)1093   public final Policy setIamPolicy(
1094       String project,
1095       String zone,
1096       String resource,
1097       ZoneSetPolicyRequest zoneSetPolicyRequestResource) {
1098     SetIamPolicyReservationRequest request =
1099         SetIamPolicyReservationRequest.newBuilder()
1100             .setProject(project)
1101             .setZone(zone)
1102             .setResource(resource)
1103             .setZoneSetPolicyRequestResource(zoneSetPolicyRequestResource)
1104             .build();
1105     return setIamPolicy(request);
1106   }
1107 
1108   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1109   /**
1110    * Sets the access control policy on the specified resource. Replaces any existing policy.
1111    *
1112    * <p>Sample code:
1113    *
1114    * <pre>{@code
1115    * // This snippet has been automatically generated and should be regarded as a code template only.
1116    * // It will require modifications to work:
1117    * // - It may require correct/in-range values for request initialization.
1118    * // - It may require specifying regional endpoints when creating the service client as shown in
1119    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1120    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1121    *   SetIamPolicyReservationRequest request =
1122    *       SetIamPolicyReservationRequest.newBuilder()
1123    *           .setProject("project-309310695")
1124    *           .setResource("resource-341064690")
1125    *           .setZone("zone3744684")
1126    *           .setZoneSetPolicyRequestResource(ZoneSetPolicyRequest.newBuilder().build())
1127    *           .build();
1128    *   Policy response = reservationsClient.setIamPolicy(request);
1129    * }
1130    * }</pre>
1131    *
1132    * @param request The request object containing all of the parameters for the API call.
1133    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1134    */
setIamPolicy(SetIamPolicyReservationRequest request)1135   public final Policy setIamPolicy(SetIamPolicyReservationRequest request) {
1136     return setIamPolicyCallable().call(request);
1137   }
1138 
1139   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1140   /**
1141    * Sets the access control policy on the specified resource. Replaces any existing policy.
1142    *
1143    * <p>Sample code:
1144    *
1145    * <pre>{@code
1146    * // This snippet has been automatically generated and should be regarded as a code template only.
1147    * // It will require modifications to work:
1148    * // - It may require correct/in-range values for request initialization.
1149    * // - It may require specifying regional endpoints when creating the service client as shown in
1150    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1151    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1152    *   SetIamPolicyReservationRequest request =
1153    *       SetIamPolicyReservationRequest.newBuilder()
1154    *           .setProject("project-309310695")
1155    *           .setResource("resource-341064690")
1156    *           .setZone("zone3744684")
1157    *           .setZoneSetPolicyRequestResource(ZoneSetPolicyRequest.newBuilder().build())
1158    *           .build();
1159    *   ApiFuture<Policy> future = reservationsClient.setIamPolicyCallable().futureCall(request);
1160    *   // Do something.
1161    *   Policy response = future.get();
1162    * }
1163    * }</pre>
1164    */
setIamPolicyCallable()1165   public final UnaryCallable<SetIamPolicyReservationRequest, Policy> setIamPolicyCallable() {
1166     return stub.setIamPolicyCallable();
1167   }
1168 
1169   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1170   /**
1171    * Returns permissions that a caller has on the specified resource.
1172    *
1173    * <p>Sample code:
1174    *
1175    * <pre>{@code
1176    * // This snippet has been automatically generated and should be regarded as a code template only.
1177    * // It will require modifications to work:
1178    * // - It may require correct/in-range values for request initialization.
1179    * // - It may require specifying regional endpoints when creating the service client as shown in
1180    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1181    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1182    *   String project = "project-309310695";
1183    *   String zone = "zone3744684";
1184    *   String resource = "resource-341064690";
1185    *   TestPermissionsRequest testPermissionsRequestResource =
1186    *       TestPermissionsRequest.newBuilder().build();
1187    *   TestPermissionsResponse response =
1188    *       reservationsClient.testIamPermissions(
1189    *           project, zone, resource, testPermissionsRequestResource);
1190    * }
1191    * }</pre>
1192    *
1193    * @param project Project ID for this request.
1194    * @param zone The name of the zone for this request.
1195    * @param resource Name or id of the resource for this request.
1196    * @param testPermissionsRequestResource The body resource for this request
1197    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1198    */
testIamPermissions( String project, String zone, String resource, TestPermissionsRequest testPermissionsRequestResource)1199   public final TestPermissionsResponse testIamPermissions(
1200       String project,
1201       String zone,
1202       String resource,
1203       TestPermissionsRequest testPermissionsRequestResource) {
1204     TestIamPermissionsReservationRequest request =
1205         TestIamPermissionsReservationRequest.newBuilder()
1206             .setProject(project)
1207             .setZone(zone)
1208             .setResource(resource)
1209             .setTestPermissionsRequestResource(testPermissionsRequestResource)
1210             .build();
1211     return testIamPermissions(request);
1212   }
1213 
1214   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1215   /**
1216    * Returns permissions that a caller has on the specified resource.
1217    *
1218    * <p>Sample code:
1219    *
1220    * <pre>{@code
1221    * // This snippet has been automatically generated and should be regarded as a code template only.
1222    * // It will require modifications to work:
1223    * // - It may require correct/in-range values for request initialization.
1224    * // - It may require specifying regional endpoints when creating the service client as shown in
1225    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1226    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1227    *   TestIamPermissionsReservationRequest request =
1228    *       TestIamPermissionsReservationRequest.newBuilder()
1229    *           .setProject("project-309310695")
1230    *           .setResource("resource-341064690")
1231    *           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
1232    *           .setZone("zone3744684")
1233    *           .build();
1234    *   TestPermissionsResponse response = reservationsClient.testIamPermissions(request);
1235    * }
1236    * }</pre>
1237    *
1238    * @param request The request object containing all of the parameters for the API call.
1239    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1240    */
testIamPermissions( TestIamPermissionsReservationRequest request)1241   public final TestPermissionsResponse testIamPermissions(
1242       TestIamPermissionsReservationRequest request) {
1243     return testIamPermissionsCallable().call(request);
1244   }
1245 
1246   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1247   /**
1248    * Returns permissions that a caller has on the specified resource.
1249    *
1250    * <p>Sample code:
1251    *
1252    * <pre>{@code
1253    * // This snippet has been automatically generated and should be regarded as a code template only.
1254    * // It will require modifications to work:
1255    * // - It may require correct/in-range values for request initialization.
1256    * // - It may require specifying regional endpoints when creating the service client as shown in
1257    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1258    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1259    *   TestIamPermissionsReservationRequest request =
1260    *       TestIamPermissionsReservationRequest.newBuilder()
1261    *           .setProject("project-309310695")
1262    *           .setResource("resource-341064690")
1263    *           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
1264    *           .setZone("zone3744684")
1265    *           .build();
1266    *   ApiFuture<TestPermissionsResponse> future =
1267    *       reservationsClient.testIamPermissionsCallable().futureCall(request);
1268    *   // Do something.
1269    *   TestPermissionsResponse response = future.get();
1270    * }
1271    * }</pre>
1272    */
1273   public final UnaryCallable<TestIamPermissionsReservationRequest, TestPermissionsResponse>
testIamPermissionsCallable()1274       testIamPermissionsCallable() {
1275     return stub.testIamPermissionsCallable();
1276   }
1277 
1278   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1279   /**
1280    * Update share settings of the reservation.
1281    *
1282    * <p>Sample code:
1283    *
1284    * <pre>{@code
1285    * // This snippet has been automatically generated and should be regarded as a code template only.
1286    * // It will require modifications to work:
1287    * // - It may require correct/in-range values for request initialization.
1288    * // - It may require specifying regional endpoints when creating the service client as shown in
1289    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1290    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1291    *   String project = "project-309310695";
1292    *   String zone = "zone3744684";
1293    *   String reservation = "reservation-1563081780";
1294    *   Reservation reservationResource = Reservation.newBuilder().build();
1295    *   Operation response =
1296    *       reservationsClient.updateAsync(project, zone, reservation, reservationResource).get();
1297    * }
1298    * }</pre>
1299    *
1300    * @param project Project ID for this request.
1301    * @param zone Name of the zone for this request.
1302    * @param reservation Name of the reservation to update.
1303    * @param reservationResource The body resource for this request
1304    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1305    */
updateAsync( String project, String zone, String reservation, Reservation reservationResource)1306   public final OperationFuture<Operation, Operation> updateAsync(
1307       String project, String zone, String reservation, Reservation reservationResource) {
1308     UpdateReservationRequest request =
1309         UpdateReservationRequest.newBuilder()
1310             .setProject(project)
1311             .setZone(zone)
1312             .setReservation(reservation)
1313             .setReservationResource(reservationResource)
1314             .build();
1315     return updateAsync(request);
1316   }
1317 
1318   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1319   /**
1320    * Update share settings of the reservation.
1321    *
1322    * <p>Sample code:
1323    *
1324    * <pre>{@code
1325    * // This snippet has been automatically generated and should be regarded as a code template only.
1326    * // It will require modifications to work:
1327    * // - It may require correct/in-range values for request initialization.
1328    * // - It may require specifying regional endpoints when creating the service client as shown in
1329    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1330    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1331    *   UpdateReservationRequest request =
1332    *       UpdateReservationRequest.newBuilder()
1333    *           .setPaths("paths106438894")
1334    *           .setProject("project-309310695")
1335    *           .setRequestId("requestId693933066")
1336    *           .setReservation("reservation-1563081780")
1337    *           .setReservationResource(Reservation.newBuilder().build())
1338    *           .setUpdateMask("updateMask-296147115")
1339    *           .setZone("zone3744684")
1340    *           .build();
1341    *   Operation response = reservationsClient.updateAsync(request).get();
1342    * }
1343    * }</pre>
1344    *
1345    * @param request The request object containing all of the parameters for the API call.
1346    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1347    */
1348   @BetaApi(
1349       "The surface for long-running operations is not stable yet and may change in the future.")
updateAsync(UpdateReservationRequest request)1350   public final OperationFuture<Operation, Operation> updateAsync(UpdateReservationRequest request) {
1351     return updateOperationCallable().futureCall(request);
1352   }
1353 
1354   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1355   /**
1356    * Update share settings of the reservation.
1357    *
1358    * <p>Sample code:
1359    *
1360    * <pre>{@code
1361    * // This snippet has been automatically generated and should be regarded as a code template only.
1362    * // It will require modifications to work:
1363    * // - It may require correct/in-range values for request initialization.
1364    * // - It may require specifying regional endpoints when creating the service client as shown in
1365    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1366    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1367    *   UpdateReservationRequest request =
1368    *       UpdateReservationRequest.newBuilder()
1369    *           .setPaths("paths106438894")
1370    *           .setProject("project-309310695")
1371    *           .setRequestId("requestId693933066")
1372    *           .setReservation("reservation-1563081780")
1373    *           .setReservationResource(Reservation.newBuilder().build())
1374    *           .setUpdateMask("updateMask-296147115")
1375    *           .setZone("zone3744684")
1376    *           .build();
1377    *   OperationFuture<Operation, Operation> future =
1378    *       reservationsClient.updateOperationCallable().futureCall(request);
1379    *   // Do something.
1380    *   Operation response = future.get();
1381    * }
1382    * }</pre>
1383    */
1384   public final OperationCallable<UpdateReservationRequest, Operation, Operation>
updateOperationCallable()1385       updateOperationCallable() {
1386     return stub.updateOperationCallable();
1387   }
1388 
1389   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1390   /**
1391    * Update share settings of the reservation.
1392    *
1393    * <p>Sample code:
1394    *
1395    * <pre>{@code
1396    * // This snippet has been automatically generated and should be regarded as a code template only.
1397    * // It will require modifications to work:
1398    * // - It may require correct/in-range values for request initialization.
1399    * // - It may require specifying regional endpoints when creating the service client as shown in
1400    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1401    * try (ReservationsClient reservationsClient = ReservationsClient.create()) {
1402    *   UpdateReservationRequest request =
1403    *       UpdateReservationRequest.newBuilder()
1404    *           .setPaths("paths106438894")
1405    *           .setProject("project-309310695")
1406    *           .setRequestId("requestId693933066")
1407    *           .setReservation("reservation-1563081780")
1408    *           .setReservationResource(Reservation.newBuilder().build())
1409    *           .setUpdateMask("updateMask-296147115")
1410    *           .setZone("zone3744684")
1411    *           .build();
1412    *   ApiFuture<Operation> future = reservationsClient.updateCallable().futureCall(request);
1413    *   // Do something.
1414    *   Operation response = future.get();
1415    * }
1416    * }</pre>
1417    */
updateCallable()1418   public final UnaryCallable<UpdateReservationRequest, Operation> updateCallable() {
1419     return stub.updateCallable();
1420   }
1421 
1422   @Override
close()1423   public final void close() {
1424     stub.close();
1425   }
1426 
1427   @Override
shutdown()1428   public void shutdown() {
1429     stub.shutdown();
1430   }
1431 
1432   @Override
isShutdown()1433   public boolean isShutdown() {
1434     return stub.isShutdown();
1435   }
1436 
1437   @Override
isTerminated()1438   public boolean isTerminated() {
1439     return stub.isTerminated();
1440   }
1441 
1442   @Override
shutdownNow()1443   public void shutdownNow() {
1444     stub.shutdownNow();
1445   }
1446 
1447   @Override
awaitTermination(long duration, TimeUnit unit)1448   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1449     return stub.awaitTermination(duration, unit);
1450   }
1451 
1452   public static class AggregatedListPagedResponse
1453       extends AbstractPagedListResponse<
1454           AggregatedListReservationsRequest,
1455           ReservationAggregatedList,
1456           Map.Entry<String, ReservationsScopedList>,
1457           AggregatedListPage,
1458           AggregatedListFixedSizeCollection> {
1459 
createAsync( PageContext< AggregatedListReservationsRequest, ReservationAggregatedList, Map.Entry<String, ReservationsScopedList>> context, ApiFuture<ReservationAggregatedList> futureResponse)1460     public static ApiFuture<AggregatedListPagedResponse> createAsync(
1461         PageContext<
1462                 AggregatedListReservationsRequest,
1463                 ReservationAggregatedList,
1464                 Map.Entry<String, ReservationsScopedList>>
1465             context,
1466         ApiFuture<ReservationAggregatedList> futureResponse) {
1467       ApiFuture<AggregatedListPage> futurePage =
1468           AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse);
1469       return ApiFutures.transform(
1470           futurePage,
1471           input -> new AggregatedListPagedResponse(input),
1472           MoreExecutors.directExecutor());
1473     }
1474 
AggregatedListPagedResponse(AggregatedListPage page)1475     private AggregatedListPagedResponse(AggregatedListPage page) {
1476       super(page, AggregatedListFixedSizeCollection.createEmptyCollection());
1477     }
1478   }
1479 
1480   public static class AggregatedListPage
1481       extends AbstractPage<
1482           AggregatedListReservationsRequest,
1483           ReservationAggregatedList,
1484           Map.Entry<String, ReservationsScopedList>,
1485           AggregatedListPage> {
1486 
AggregatedListPage( PageContext< AggregatedListReservationsRequest, ReservationAggregatedList, Map.Entry<String, ReservationsScopedList>> context, ReservationAggregatedList response)1487     private AggregatedListPage(
1488         PageContext<
1489                 AggregatedListReservationsRequest,
1490                 ReservationAggregatedList,
1491                 Map.Entry<String, ReservationsScopedList>>
1492             context,
1493         ReservationAggregatedList response) {
1494       super(context, response);
1495     }
1496 
createEmptyPage()1497     private static AggregatedListPage createEmptyPage() {
1498       return new AggregatedListPage(null, null);
1499     }
1500 
1501     @Override
createPage( PageContext< AggregatedListReservationsRequest, ReservationAggregatedList, Map.Entry<String, ReservationsScopedList>> context, ReservationAggregatedList response)1502     protected AggregatedListPage createPage(
1503         PageContext<
1504                 AggregatedListReservationsRequest,
1505                 ReservationAggregatedList,
1506                 Map.Entry<String, ReservationsScopedList>>
1507             context,
1508         ReservationAggregatedList response) {
1509       return new AggregatedListPage(context, response);
1510     }
1511 
1512     @Override
createPageAsync( PageContext< AggregatedListReservationsRequest, ReservationAggregatedList, Map.Entry<String, ReservationsScopedList>> context, ApiFuture<ReservationAggregatedList> futureResponse)1513     public ApiFuture<AggregatedListPage> createPageAsync(
1514         PageContext<
1515                 AggregatedListReservationsRequest,
1516                 ReservationAggregatedList,
1517                 Map.Entry<String, ReservationsScopedList>>
1518             context,
1519         ApiFuture<ReservationAggregatedList> futureResponse) {
1520       return super.createPageAsync(context, futureResponse);
1521     }
1522   }
1523 
1524   public static class AggregatedListFixedSizeCollection
1525       extends AbstractFixedSizeCollection<
1526           AggregatedListReservationsRequest,
1527           ReservationAggregatedList,
1528           Map.Entry<String, ReservationsScopedList>,
1529           AggregatedListPage,
1530           AggregatedListFixedSizeCollection> {
1531 
AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize)1532     private AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize) {
1533       super(pages, collectionSize);
1534     }
1535 
createEmptyCollection()1536     private static AggregatedListFixedSizeCollection createEmptyCollection() {
1537       return new AggregatedListFixedSizeCollection(null, 0);
1538     }
1539 
1540     @Override
createCollection( List<AggregatedListPage> pages, int collectionSize)1541     protected AggregatedListFixedSizeCollection createCollection(
1542         List<AggregatedListPage> pages, int collectionSize) {
1543       return new AggregatedListFixedSizeCollection(pages, collectionSize);
1544     }
1545   }
1546 
1547   public static class ListPagedResponse
1548       extends AbstractPagedListResponse<
1549           ListReservationsRequest,
1550           ReservationList,
1551           Reservation,
1552           ListPage,
1553           ListFixedSizeCollection> {
1554 
createAsync( PageContext<ListReservationsRequest, ReservationList, Reservation> context, ApiFuture<ReservationList> futureResponse)1555     public static ApiFuture<ListPagedResponse> createAsync(
1556         PageContext<ListReservationsRequest, ReservationList, Reservation> context,
1557         ApiFuture<ReservationList> futureResponse) {
1558       ApiFuture<ListPage> futurePage =
1559           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
1560       return ApiFutures.transform(
1561           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
1562     }
1563 
ListPagedResponse(ListPage page)1564     private ListPagedResponse(ListPage page) {
1565       super(page, ListFixedSizeCollection.createEmptyCollection());
1566     }
1567   }
1568 
1569   public static class ListPage
1570       extends AbstractPage<ListReservationsRequest, ReservationList, Reservation, ListPage> {
1571 
ListPage( PageContext<ListReservationsRequest, ReservationList, Reservation> context, ReservationList response)1572     private ListPage(
1573         PageContext<ListReservationsRequest, ReservationList, Reservation> context,
1574         ReservationList response) {
1575       super(context, response);
1576     }
1577 
createEmptyPage()1578     private static ListPage createEmptyPage() {
1579       return new ListPage(null, null);
1580     }
1581 
1582     @Override
createPage( PageContext<ListReservationsRequest, ReservationList, Reservation> context, ReservationList response)1583     protected ListPage createPage(
1584         PageContext<ListReservationsRequest, ReservationList, Reservation> context,
1585         ReservationList response) {
1586       return new ListPage(context, response);
1587     }
1588 
1589     @Override
createPageAsync( PageContext<ListReservationsRequest, ReservationList, Reservation> context, ApiFuture<ReservationList> futureResponse)1590     public ApiFuture<ListPage> createPageAsync(
1591         PageContext<ListReservationsRequest, ReservationList, Reservation> context,
1592         ApiFuture<ReservationList> futureResponse) {
1593       return super.createPageAsync(context, futureResponse);
1594     }
1595   }
1596 
1597   public static class ListFixedSizeCollection
1598       extends AbstractFixedSizeCollection<
1599           ListReservationsRequest,
1600           ReservationList,
1601           Reservation,
1602           ListPage,
1603           ListFixedSizeCollection> {
1604 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1605     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
1606       super(pages, collectionSize);
1607     }
1608 
createEmptyCollection()1609     private static ListFixedSizeCollection createEmptyCollection() {
1610       return new ListFixedSizeCollection(null, 0);
1611     }
1612 
1613     @Override
createCollection(List<ListPage> pages, int collectionSize)1614     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
1615       return new ListFixedSizeCollection(pages, collectionSize);
1616     }
1617   }
1618 }
1619