• 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.InstanceTemplatesStub;
31 import com.google.cloud.compute.v1.stub.InstanceTemplatesStubSettings;
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 InstanceTemplates 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 (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
53  *   String project = "project-309310695";
54  *   String instanceTemplate = "instanceTemplate1009541167";
55  *   InstanceTemplate response = instanceTemplatesClient.get(project, instanceTemplate);
56  * }
57  * }</pre>
58  *
59  * <p>Note: close() needs to be called on the InstanceTemplatesClient object to clean up resources
60  * such as threads. In the example above, try-with-resources is used, which automatically calls
61  * 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 InstanceTemplatesSettings 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  * InstanceTemplatesSettings instanceTemplatesSettings =
95  *     InstanceTemplatesSettings.newBuilder()
96  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
97  *         .build();
98  * InstanceTemplatesClient instanceTemplatesClient =
99  *     InstanceTemplatesClient.create(instanceTemplatesSettings);
100  * }</pre>
101  *
102  * <p>To customize the endpoint:
103  *
104  * <pre>{@code
105  * // This snippet has been automatically generated and should be regarded as a code template only.
106  * // It will require modifications to work:
107  * // - It may require correct/in-range values for request initialization.
108  * // - It may require specifying regional endpoints when creating the service client as shown in
109  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
110  * InstanceTemplatesSettings instanceTemplatesSettings =
111  *     InstanceTemplatesSettings.newBuilder().setEndpoint(myEndpoint).build();
112  * InstanceTemplatesClient instanceTemplatesClient =
113  *     InstanceTemplatesClient.create(instanceTemplatesSettings);
114  * }</pre>
115  *
116  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
117  */
118 @Generated("by gapic-generator-java")
119 public class InstanceTemplatesClient implements BackgroundResource {
120   private final InstanceTemplatesSettings settings;
121   private final InstanceTemplatesStub stub;
122 
123   /** Constructs an instance of InstanceTemplatesClient with default settings. */
create()124   public static final InstanceTemplatesClient create() throws IOException {
125     return create(InstanceTemplatesSettings.newBuilder().build());
126   }
127 
128   /**
129    * Constructs an instance of InstanceTemplatesClient, using the given settings. The channels are
130    * created based on the settings passed in, or defaults for any settings that are not set.
131    */
create(InstanceTemplatesSettings settings)132   public static final InstanceTemplatesClient create(InstanceTemplatesSettings settings)
133       throws IOException {
134     return new InstanceTemplatesClient(settings);
135   }
136 
137   /**
138    * Constructs an instance of InstanceTemplatesClient, using the given stub for making calls. This
139    * is for advanced usage - prefer using create(InstanceTemplatesSettings).
140    */
create(InstanceTemplatesStub stub)141   public static final InstanceTemplatesClient create(InstanceTemplatesStub stub) {
142     return new InstanceTemplatesClient(stub);
143   }
144 
145   /**
146    * Constructs an instance of InstanceTemplatesClient, using the given settings. This is protected
147    * so that it is easy to make a subclass, but otherwise, the static factory methods should be
148    * preferred.
149    */
InstanceTemplatesClient(InstanceTemplatesSettings settings)150   protected InstanceTemplatesClient(InstanceTemplatesSettings settings) throws IOException {
151     this.settings = settings;
152     this.stub = ((InstanceTemplatesStubSettings) settings.getStubSettings()).createStub();
153   }
154 
InstanceTemplatesClient(InstanceTemplatesStub stub)155   protected InstanceTemplatesClient(InstanceTemplatesStub stub) {
156     this.settings = null;
157     this.stub = stub;
158   }
159 
getSettings()160   public final InstanceTemplatesSettings getSettings() {
161     return settings;
162   }
163 
getStub()164   public InstanceTemplatesStub getStub() {
165     return stub;
166   }
167 
168   // AUTO-GENERATED DOCUMENTATION AND METHOD.
169   /**
170    * Retrieves the list of all InstanceTemplates resources, regional and global, available to the
171    * specified project.
172    *
173    * <p>Sample code:
174    *
175    * <pre>{@code
176    * // This snippet has been automatically generated and should be regarded as a code template only.
177    * // It will require modifications to work:
178    * // - It may require correct/in-range values for request initialization.
179    * // - It may require specifying regional endpoints when creating the service client as shown in
180    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
181    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
182    *   String project = "project-309310695";
183    *   for (Map.Entry<String, InstanceTemplatesScopedList> element :
184    *       instanceTemplatesClient.aggregatedList(project).iterateAll()) {
185    *     // doThingsWith(element);
186    *   }
187    * }
188    * }</pre>
189    *
190    * @param project Name of the project scoping this request.
191    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
192    */
aggregatedList(String project)193   public final AggregatedListPagedResponse aggregatedList(String project) {
194     AggregatedListInstanceTemplatesRequest request =
195         AggregatedListInstanceTemplatesRequest.newBuilder().setProject(project).build();
196     return aggregatedList(request);
197   }
198 
199   // AUTO-GENERATED DOCUMENTATION AND METHOD.
200   /**
201    * Retrieves the list of all InstanceTemplates resources, regional and global, available to the
202    * specified project.
203    *
204    * <p>Sample code:
205    *
206    * <pre>{@code
207    * // This snippet has been automatically generated and should be regarded as a code template only.
208    * // It will require modifications to work:
209    * // - It may require correct/in-range values for request initialization.
210    * // - It may require specifying regional endpoints when creating the service client as shown in
211    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
212    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
213    *   AggregatedListInstanceTemplatesRequest request =
214    *       AggregatedListInstanceTemplatesRequest.newBuilder()
215    *           .setFilter("filter-1274492040")
216    *           .setIncludeAllScopes(true)
217    *           .setMaxResults(1128457243)
218    *           .setOrderBy("orderBy-1207110587")
219    *           .setPageToken("pageToken873572522")
220    *           .setProject("project-309310695")
221    *           .setReturnPartialSuccess(true)
222    *           .build();
223    *   for (Map.Entry<String, InstanceTemplatesScopedList> element :
224    *       instanceTemplatesClient.aggregatedList(request).iterateAll()) {
225    *     // doThingsWith(element);
226    *   }
227    * }
228    * }</pre>
229    *
230    * @param request The request object containing all of the parameters for the API call.
231    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
232    */
aggregatedList( AggregatedListInstanceTemplatesRequest request)233   public final AggregatedListPagedResponse aggregatedList(
234       AggregatedListInstanceTemplatesRequest request) {
235     return aggregatedListPagedCallable().call(request);
236   }
237 
238   // AUTO-GENERATED DOCUMENTATION AND METHOD.
239   /**
240    * Retrieves the list of all InstanceTemplates resources, regional and global, available to the
241    * specified project.
242    *
243    * <p>Sample code:
244    *
245    * <pre>{@code
246    * // This snippet has been automatically generated and should be regarded as a code template only.
247    * // It will require modifications to work:
248    * // - It may require correct/in-range values for request initialization.
249    * // - It may require specifying regional endpoints when creating the service client as shown in
250    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
251    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
252    *   AggregatedListInstanceTemplatesRequest request =
253    *       AggregatedListInstanceTemplatesRequest.newBuilder()
254    *           .setFilter("filter-1274492040")
255    *           .setIncludeAllScopes(true)
256    *           .setMaxResults(1128457243)
257    *           .setOrderBy("orderBy-1207110587")
258    *           .setPageToken("pageToken873572522")
259    *           .setProject("project-309310695")
260    *           .setReturnPartialSuccess(true)
261    *           .build();
262    *   ApiFuture<Map.Entry<String, InstanceTemplatesScopedList>> future =
263    *       instanceTemplatesClient.aggregatedListPagedCallable().futureCall(request);
264    *   // Do something.
265    *   for (Map.Entry<String, InstanceTemplatesScopedList> element : future.get().iterateAll()) {
266    *     // doThingsWith(element);
267    *   }
268    * }
269    * }</pre>
270    */
271   public final UnaryCallable<AggregatedListInstanceTemplatesRequest, AggregatedListPagedResponse>
aggregatedListPagedCallable()272       aggregatedListPagedCallable() {
273     return stub.aggregatedListPagedCallable();
274   }
275 
276   // AUTO-GENERATED DOCUMENTATION AND METHOD.
277   /**
278    * Retrieves the list of all InstanceTemplates resources, regional and global, available to the
279    * specified project.
280    *
281    * <p>Sample code:
282    *
283    * <pre>{@code
284    * // This snippet has been automatically generated and should be regarded as a code template only.
285    * // It will require modifications to work:
286    * // - It may require correct/in-range values for request initialization.
287    * // - It may require specifying regional endpoints when creating the service client as shown in
288    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
289    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
290    *   AggregatedListInstanceTemplatesRequest request =
291    *       AggregatedListInstanceTemplatesRequest.newBuilder()
292    *           .setFilter("filter-1274492040")
293    *           .setIncludeAllScopes(true)
294    *           .setMaxResults(1128457243)
295    *           .setOrderBy("orderBy-1207110587")
296    *           .setPageToken("pageToken873572522")
297    *           .setProject("project-309310695")
298    *           .setReturnPartialSuccess(true)
299    *           .build();
300    *   while (true) {
301    *     InstanceTemplateAggregatedList response =
302    *         instanceTemplatesClient.aggregatedListCallable().call(request);
303    *     for (Map.Entry<String, InstanceTemplatesScopedList> element : response.getItemsList()) {
304    *       // doThingsWith(element);
305    *     }
306    *     String nextPageToken = response.getNextPageToken();
307    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
308    *       request = request.toBuilder().setPageToken(nextPageToken).build();
309    *     } else {
310    *       break;
311    *     }
312    *   }
313    * }
314    * }</pre>
315    */
316   public final UnaryCallable<AggregatedListInstanceTemplatesRequest, InstanceTemplateAggregatedList>
aggregatedListCallable()317       aggregatedListCallable() {
318     return stub.aggregatedListCallable();
319   }
320 
321   // AUTO-GENERATED DOCUMENTATION AND METHOD.
322   /**
323    * Deletes the specified instance template. Deleting an instance template is permanent and cannot
324    * be undone. It is not possible to delete templates that are already in use by a managed instance
325    * group.
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 (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
336    *   String project = "project-309310695";
337    *   String instanceTemplate = "instanceTemplate1009541167";
338    *   Operation response = instanceTemplatesClient.deleteAsync(project, instanceTemplate).get();
339    * }
340    * }</pre>
341    *
342    * @param project Project ID for this request.
343    * @param instanceTemplate The name of the instance template to delete.
344    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
345    */
deleteAsync( String project, String instanceTemplate)346   public final OperationFuture<Operation, Operation> deleteAsync(
347       String project, String instanceTemplate) {
348     DeleteInstanceTemplateRequest request =
349         DeleteInstanceTemplateRequest.newBuilder()
350             .setProject(project)
351             .setInstanceTemplate(instanceTemplate)
352             .build();
353     return deleteAsync(request);
354   }
355 
356   // AUTO-GENERATED DOCUMENTATION AND METHOD.
357   /**
358    * Deletes the specified instance template. Deleting an instance template is permanent and cannot
359    * be undone. It is not possible to delete templates that are already in use by a managed instance
360    * group.
361    *
362    * <p>Sample code:
363    *
364    * <pre>{@code
365    * // This snippet has been automatically generated and should be regarded as a code template only.
366    * // It will require modifications to work:
367    * // - It may require correct/in-range values for request initialization.
368    * // - It may require specifying regional endpoints when creating the service client as shown in
369    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
370    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
371    *   DeleteInstanceTemplateRequest request =
372    *       DeleteInstanceTemplateRequest.newBuilder()
373    *           .setInstanceTemplate("instanceTemplate1009541167")
374    *           .setProject("project-309310695")
375    *           .setRequestId("requestId693933066")
376    *           .build();
377    *   Operation response = instanceTemplatesClient.deleteAsync(request).get();
378    * }
379    * }</pre>
380    *
381    * @param request The request object containing all of the parameters for the API call.
382    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
383    */
384   @BetaApi(
385       "The surface for long-running operations is not stable yet and may change in the future.")
deleteAsync( DeleteInstanceTemplateRequest request)386   public final OperationFuture<Operation, Operation> deleteAsync(
387       DeleteInstanceTemplateRequest request) {
388     return deleteOperationCallable().futureCall(request);
389   }
390 
391   // AUTO-GENERATED DOCUMENTATION AND METHOD.
392   /**
393    * Deletes the specified instance template. Deleting an instance template is permanent and cannot
394    * be undone. It is not possible to delete templates that are already in use by a managed instance
395    * group.
396    *
397    * <p>Sample code:
398    *
399    * <pre>{@code
400    * // This snippet has been automatically generated and should be regarded as a code template only.
401    * // It will require modifications to work:
402    * // - It may require correct/in-range values for request initialization.
403    * // - It may require specifying regional endpoints when creating the service client as shown in
404    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
405    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
406    *   DeleteInstanceTemplateRequest request =
407    *       DeleteInstanceTemplateRequest.newBuilder()
408    *           .setInstanceTemplate("instanceTemplate1009541167")
409    *           .setProject("project-309310695")
410    *           .setRequestId("requestId693933066")
411    *           .build();
412    *   OperationFuture<Operation, Operation> future =
413    *       instanceTemplatesClient.deleteOperationCallable().futureCall(request);
414    *   // Do something.
415    *   Operation response = future.get();
416    * }
417    * }</pre>
418    */
419   public final OperationCallable<DeleteInstanceTemplateRequest, Operation, Operation>
deleteOperationCallable()420       deleteOperationCallable() {
421     return stub.deleteOperationCallable();
422   }
423 
424   // AUTO-GENERATED DOCUMENTATION AND METHOD.
425   /**
426    * Deletes the specified instance template. Deleting an instance template is permanent and cannot
427    * be undone. It is not possible to delete templates that are already in use by a managed instance
428    * group.
429    *
430    * <p>Sample code:
431    *
432    * <pre>{@code
433    * // This snippet has been automatically generated and should be regarded as a code template only.
434    * // It will require modifications to work:
435    * // - It may require correct/in-range values for request initialization.
436    * // - It may require specifying regional endpoints when creating the service client as shown in
437    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
438    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
439    *   DeleteInstanceTemplateRequest request =
440    *       DeleteInstanceTemplateRequest.newBuilder()
441    *           .setInstanceTemplate("instanceTemplate1009541167")
442    *           .setProject("project-309310695")
443    *           .setRequestId("requestId693933066")
444    *           .build();
445    *   ApiFuture<Operation> future = instanceTemplatesClient.deleteCallable().futureCall(request);
446    *   // Do something.
447    *   Operation response = future.get();
448    * }
449    * }</pre>
450    */
deleteCallable()451   public final UnaryCallable<DeleteInstanceTemplateRequest, Operation> deleteCallable() {
452     return stub.deleteCallable();
453   }
454 
455   // AUTO-GENERATED DOCUMENTATION AND METHOD.
456   /**
457    * Returns the specified instance template.
458    *
459    * <p>Sample code:
460    *
461    * <pre>{@code
462    * // This snippet has been automatically generated and should be regarded as a code template only.
463    * // It will require modifications to work:
464    * // - It may require correct/in-range values for request initialization.
465    * // - It may require specifying regional endpoints when creating the service client as shown in
466    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
467    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
468    *   String project = "project-309310695";
469    *   String instanceTemplate = "instanceTemplate1009541167";
470    *   InstanceTemplate response = instanceTemplatesClient.get(project, instanceTemplate);
471    * }
472    * }</pre>
473    *
474    * @param project Project ID for this request.
475    * @param instanceTemplate The name of the instance template.
476    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
477    */
get(String project, String instanceTemplate)478   public final InstanceTemplate get(String project, String instanceTemplate) {
479     GetInstanceTemplateRequest request =
480         GetInstanceTemplateRequest.newBuilder()
481             .setProject(project)
482             .setInstanceTemplate(instanceTemplate)
483             .build();
484     return get(request);
485   }
486 
487   // AUTO-GENERATED DOCUMENTATION AND METHOD.
488   /**
489    * Returns the specified instance template.
490    *
491    * <p>Sample code:
492    *
493    * <pre>{@code
494    * // This snippet has been automatically generated and should be regarded as a code template only.
495    * // It will require modifications to work:
496    * // - It may require correct/in-range values for request initialization.
497    * // - It may require specifying regional endpoints when creating the service client as shown in
498    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
499    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
500    *   GetInstanceTemplateRequest request =
501    *       GetInstanceTemplateRequest.newBuilder()
502    *           .setInstanceTemplate("instanceTemplate1009541167")
503    *           .setProject("project-309310695")
504    *           .build();
505    *   InstanceTemplate response = instanceTemplatesClient.get(request);
506    * }
507    * }</pre>
508    *
509    * @param request The request object containing all of the parameters for the API call.
510    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
511    */
get(GetInstanceTemplateRequest request)512   public final InstanceTemplate get(GetInstanceTemplateRequest request) {
513     return getCallable().call(request);
514   }
515 
516   // AUTO-GENERATED DOCUMENTATION AND METHOD.
517   /**
518    * Returns the specified instance template.
519    *
520    * <p>Sample code:
521    *
522    * <pre>{@code
523    * // This snippet has been automatically generated and should be regarded as a code template only.
524    * // It will require modifications to work:
525    * // - It may require correct/in-range values for request initialization.
526    * // - It may require specifying regional endpoints when creating the service client as shown in
527    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
528    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
529    *   GetInstanceTemplateRequest request =
530    *       GetInstanceTemplateRequest.newBuilder()
531    *           .setInstanceTemplate("instanceTemplate1009541167")
532    *           .setProject("project-309310695")
533    *           .build();
534    *   ApiFuture<InstanceTemplate> future =
535    *       instanceTemplatesClient.getCallable().futureCall(request);
536    *   // Do something.
537    *   InstanceTemplate response = future.get();
538    * }
539    * }</pre>
540    */
getCallable()541   public final UnaryCallable<GetInstanceTemplateRequest, InstanceTemplate> getCallable() {
542     return stub.getCallable();
543   }
544 
545   // AUTO-GENERATED DOCUMENTATION AND METHOD.
546   /**
547    * Gets the access control policy for a resource. May be empty if no such policy or resource
548    * exists.
549    *
550    * <p>Sample code:
551    *
552    * <pre>{@code
553    * // This snippet has been automatically generated and should be regarded as a code template only.
554    * // It will require modifications to work:
555    * // - It may require correct/in-range values for request initialization.
556    * // - It may require specifying regional endpoints when creating the service client as shown in
557    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
558    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
559    *   String project = "project-309310695";
560    *   String resource = "resource-341064690";
561    *   Policy response = instanceTemplatesClient.getIamPolicy(project, resource);
562    * }
563    * }</pre>
564    *
565    * @param project Project ID for this request.
566    * @param resource Name or id of the resource for this request.
567    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
568    */
getIamPolicy(String project, String resource)569   public final Policy getIamPolicy(String project, String resource) {
570     GetIamPolicyInstanceTemplateRequest request =
571         GetIamPolicyInstanceTemplateRequest.newBuilder()
572             .setProject(project)
573             .setResource(resource)
574             .build();
575     return getIamPolicy(request);
576   }
577 
578   // AUTO-GENERATED DOCUMENTATION AND METHOD.
579   /**
580    * Gets the access control policy for a resource. May be empty if no such policy or resource
581    * exists.
582    *
583    * <p>Sample code:
584    *
585    * <pre>{@code
586    * // This snippet has been automatically generated and should be regarded as a code template only.
587    * // It will require modifications to work:
588    * // - It may require correct/in-range values for request initialization.
589    * // - It may require specifying regional endpoints when creating the service client as shown in
590    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
591    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
592    *   GetIamPolicyInstanceTemplateRequest request =
593    *       GetIamPolicyInstanceTemplateRequest.newBuilder()
594    *           .setOptionsRequestedPolicyVersion(-574521795)
595    *           .setProject("project-309310695")
596    *           .setResource("resource-341064690")
597    *           .build();
598    *   Policy response = instanceTemplatesClient.getIamPolicy(request);
599    * }
600    * }</pre>
601    *
602    * @param request The request object containing all of the parameters for the API call.
603    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
604    */
getIamPolicy(GetIamPolicyInstanceTemplateRequest request)605   public final Policy getIamPolicy(GetIamPolicyInstanceTemplateRequest request) {
606     return getIamPolicyCallable().call(request);
607   }
608 
609   // AUTO-GENERATED DOCUMENTATION AND METHOD.
610   /**
611    * Gets the access control policy for a resource. May be empty if no such policy or resource
612    * exists.
613    *
614    * <p>Sample code:
615    *
616    * <pre>{@code
617    * // This snippet has been automatically generated and should be regarded as a code template only.
618    * // It will require modifications to work:
619    * // - It may require correct/in-range values for request initialization.
620    * // - It may require specifying regional endpoints when creating the service client as shown in
621    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
622    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
623    *   GetIamPolicyInstanceTemplateRequest request =
624    *       GetIamPolicyInstanceTemplateRequest.newBuilder()
625    *           .setOptionsRequestedPolicyVersion(-574521795)
626    *           .setProject("project-309310695")
627    *           .setResource("resource-341064690")
628    *           .build();
629    *   ApiFuture<Policy> future = instanceTemplatesClient.getIamPolicyCallable().futureCall(request);
630    *   // Do something.
631    *   Policy response = future.get();
632    * }
633    * }</pre>
634    */
getIamPolicyCallable()635   public final UnaryCallable<GetIamPolicyInstanceTemplateRequest, Policy> getIamPolicyCallable() {
636     return stub.getIamPolicyCallable();
637   }
638 
639   // AUTO-GENERATED DOCUMENTATION AND METHOD.
640   /**
641    * Creates an instance template in the specified project using the data that is included in the
642    * request. If you are creating a new template to update an existing instance group, your new
643    * instance template must use the same network or, if applicable, the same subnetwork as the
644    * original template.
645    *
646    * <p>Sample code:
647    *
648    * <pre>{@code
649    * // This snippet has been automatically generated and should be regarded as a code template only.
650    * // It will require modifications to work:
651    * // - It may require correct/in-range values for request initialization.
652    * // - It may require specifying regional endpoints when creating the service client as shown in
653    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
654    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
655    *   String project = "project-309310695";
656    *   InstanceTemplate instanceTemplateResource = InstanceTemplate.newBuilder().build();
657    *   Operation response =
658    *       instanceTemplatesClient.insertAsync(project, instanceTemplateResource).get();
659    * }
660    * }</pre>
661    *
662    * @param project Project ID for this request.
663    * @param instanceTemplateResource The body resource for this request
664    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
665    */
insertAsync( String project, InstanceTemplate instanceTemplateResource)666   public final OperationFuture<Operation, Operation> insertAsync(
667       String project, InstanceTemplate instanceTemplateResource) {
668     InsertInstanceTemplateRequest request =
669         InsertInstanceTemplateRequest.newBuilder()
670             .setProject(project)
671             .setInstanceTemplateResource(instanceTemplateResource)
672             .build();
673     return insertAsync(request);
674   }
675 
676   // AUTO-GENERATED DOCUMENTATION AND METHOD.
677   /**
678    * Creates an instance template in the specified project using the data that is included in the
679    * request. If you are creating a new template to update an existing instance group, your new
680    * instance template must use the same network or, if applicable, the same subnetwork as the
681    * original template.
682    *
683    * <p>Sample code:
684    *
685    * <pre>{@code
686    * // This snippet has been automatically generated and should be regarded as a code template only.
687    * // It will require modifications to work:
688    * // - It may require correct/in-range values for request initialization.
689    * // - It may require specifying regional endpoints when creating the service client as shown in
690    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
691    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
692    *   InsertInstanceTemplateRequest request =
693    *       InsertInstanceTemplateRequest.newBuilder()
694    *           .setInstanceTemplateResource(InstanceTemplate.newBuilder().build())
695    *           .setProject("project-309310695")
696    *           .setRequestId("requestId693933066")
697    *           .build();
698    *   Operation response = instanceTemplatesClient.insertAsync(request).get();
699    * }
700    * }</pre>
701    *
702    * @param request The request object containing all of the parameters for the API call.
703    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
704    */
705   @BetaApi(
706       "The surface for long-running operations is not stable yet and may change in the future.")
insertAsync( InsertInstanceTemplateRequest request)707   public final OperationFuture<Operation, Operation> insertAsync(
708       InsertInstanceTemplateRequest request) {
709     return insertOperationCallable().futureCall(request);
710   }
711 
712   // AUTO-GENERATED DOCUMENTATION AND METHOD.
713   /**
714    * Creates an instance template in the specified project using the data that is included in the
715    * request. If you are creating a new template to update an existing instance group, your new
716    * instance template must use the same network or, if applicable, the same subnetwork as the
717    * original template.
718    *
719    * <p>Sample code:
720    *
721    * <pre>{@code
722    * // This snippet has been automatically generated and should be regarded as a code template only.
723    * // It will require modifications to work:
724    * // - It may require correct/in-range values for request initialization.
725    * // - It may require specifying regional endpoints when creating the service client as shown in
726    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
727    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
728    *   InsertInstanceTemplateRequest request =
729    *       InsertInstanceTemplateRequest.newBuilder()
730    *           .setInstanceTemplateResource(InstanceTemplate.newBuilder().build())
731    *           .setProject("project-309310695")
732    *           .setRequestId("requestId693933066")
733    *           .build();
734    *   OperationFuture<Operation, Operation> future =
735    *       instanceTemplatesClient.insertOperationCallable().futureCall(request);
736    *   // Do something.
737    *   Operation response = future.get();
738    * }
739    * }</pre>
740    */
741   public final OperationCallable<InsertInstanceTemplateRequest, Operation, Operation>
insertOperationCallable()742       insertOperationCallable() {
743     return stub.insertOperationCallable();
744   }
745 
746   // AUTO-GENERATED DOCUMENTATION AND METHOD.
747   /**
748    * Creates an instance template in the specified project using the data that is included in the
749    * request. If you are creating a new template to update an existing instance group, your new
750    * instance template must use the same network or, if applicable, the same subnetwork as the
751    * original template.
752    *
753    * <p>Sample code:
754    *
755    * <pre>{@code
756    * // This snippet has been automatically generated and should be regarded as a code template only.
757    * // It will require modifications to work:
758    * // - It may require correct/in-range values for request initialization.
759    * // - It may require specifying regional endpoints when creating the service client as shown in
760    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
761    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
762    *   InsertInstanceTemplateRequest request =
763    *       InsertInstanceTemplateRequest.newBuilder()
764    *           .setInstanceTemplateResource(InstanceTemplate.newBuilder().build())
765    *           .setProject("project-309310695")
766    *           .setRequestId("requestId693933066")
767    *           .build();
768    *   ApiFuture<Operation> future = instanceTemplatesClient.insertCallable().futureCall(request);
769    *   // Do something.
770    *   Operation response = future.get();
771    * }
772    * }</pre>
773    */
insertCallable()774   public final UnaryCallable<InsertInstanceTemplateRequest, Operation> insertCallable() {
775     return stub.insertCallable();
776   }
777 
778   // AUTO-GENERATED DOCUMENTATION AND METHOD.
779   /**
780    * Retrieves a list of instance templates that are contained within the specified project.
781    *
782    * <p>Sample code:
783    *
784    * <pre>{@code
785    * // This snippet has been automatically generated and should be regarded as a code template only.
786    * // It will require modifications to work:
787    * // - It may require correct/in-range values for request initialization.
788    * // - It may require specifying regional endpoints when creating the service client as shown in
789    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
790    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
791    *   String project = "project-309310695";
792    *   for (InstanceTemplate element : instanceTemplatesClient.list(project).iterateAll()) {
793    *     // doThingsWith(element);
794    *   }
795    * }
796    * }</pre>
797    *
798    * @param project Project ID for this request.
799    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
800    */
list(String project)801   public final ListPagedResponse list(String project) {
802     ListInstanceTemplatesRequest request =
803         ListInstanceTemplatesRequest.newBuilder().setProject(project).build();
804     return list(request);
805   }
806 
807   // AUTO-GENERATED DOCUMENTATION AND METHOD.
808   /**
809    * Retrieves a list of instance templates that are contained within the specified project.
810    *
811    * <p>Sample code:
812    *
813    * <pre>{@code
814    * // This snippet has been automatically generated and should be regarded as a code template only.
815    * // It will require modifications to work:
816    * // - It may require correct/in-range values for request initialization.
817    * // - It may require specifying regional endpoints when creating the service client as shown in
818    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
819    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
820    *   ListInstanceTemplatesRequest request =
821    *       ListInstanceTemplatesRequest.newBuilder()
822    *           .setFilter("filter-1274492040")
823    *           .setMaxResults(1128457243)
824    *           .setOrderBy("orderBy-1207110587")
825    *           .setPageToken("pageToken873572522")
826    *           .setProject("project-309310695")
827    *           .setReturnPartialSuccess(true)
828    *           .build();
829    *   for (InstanceTemplate element : instanceTemplatesClient.list(request).iterateAll()) {
830    *     // doThingsWith(element);
831    *   }
832    * }
833    * }</pre>
834    *
835    * @param request The request object containing all of the parameters for the API call.
836    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
837    */
list(ListInstanceTemplatesRequest request)838   public final ListPagedResponse list(ListInstanceTemplatesRequest request) {
839     return listPagedCallable().call(request);
840   }
841 
842   // AUTO-GENERATED DOCUMENTATION AND METHOD.
843   /**
844    * Retrieves a list of instance templates that are contained within the specified project.
845    *
846    * <p>Sample code:
847    *
848    * <pre>{@code
849    * // This snippet has been automatically generated and should be regarded as a code template only.
850    * // It will require modifications to work:
851    * // - It may require correct/in-range values for request initialization.
852    * // - It may require specifying regional endpoints when creating the service client as shown in
853    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
854    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
855    *   ListInstanceTemplatesRequest request =
856    *       ListInstanceTemplatesRequest.newBuilder()
857    *           .setFilter("filter-1274492040")
858    *           .setMaxResults(1128457243)
859    *           .setOrderBy("orderBy-1207110587")
860    *           .setPageToken("pageToken873572522")
861    *           .setProject("project-309310695")
862    *           .setReturnPartialSuccess(true)
863    *           .build();
864    *   ApiFuture<InstanceTemplate> future =
865    *       instanceTemplatesClient.listPagedCallable().futureCall(request);
866    *   // Do something.
867    *   for (InstanceTemplate element : future.get().iterateAll()) {
868    *     // doThingsWith(element);
869    *   }
870    * }
871    * }</pre>
872    */
listPagedCallable()873   public final UnaryCallable<ListInstanceTemplatesRequest, ListPagedResponse> listPagedCallable() {
874     return stub.listPagedCallable();
875   }
876 
877   // AUTO-GENERATED DOCUMENTATION AND METHOD.
878   /**
879    * Retrieves a list of instance templates that are contained within the specified project.
880    *
881    * <p>Sample code:
882    *
883    * <pre>{@code
884    * // This snippet has been automatically generated and should be regarded as a code template only.
885    * // It will require modifications to work:
886    * // - It may require correct/in-range values for request initialization.
887    * // - It may require specifying regional endpoints when creating the service client as shown in
888    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
889    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
890    *   ListInstanceTemplatesRequest request =
891    *       ListInstanceTemplatesRequest.newBuilder()
892    *           .setFilter("filter-1274492040")
893    *           .setMaxResults(1128457243)
894    *           .setOrderBy("orderBy-1207110587")
895    *           .setPageToken("pageToken873572522")
896    *           .setProject("project-309310695")
897    *           .setReturnPartialSuccess(true)
898    *           .build();
899    *   while (true) {
900    *     InstanceTemplateList response = instanceTemplatesClient.listCallable().call(request);
901    *     for (InstanceTemplate element : response.getItemsList()) {
902    *       // doThingsWith(element);
903    *     }
904    *     String nextPageToken = response.getNextPageToken();
905    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
906    *       request = request.toBuilder().setPageToken(nextPageToken).build();
907    *     } else {
908    *       break;
909    *     }
910    *   }
911    * }
912    * }</pre>
913    */
listCallable()914   public final UnaryCallable<ListInstanceTemplatesRequest, InstanceTemplateList> listCallable() {
915     return stub.listCallable();
916   }
917 
918   // AUTO-GENERATED DOCUMENTATION AND METHOD.
919   /**
920    * Sets the access control policy on the specified resource. Replaces any existing policy.
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 (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
931    *   String project = "project-309310695";
932    *   String resource = "resource-341064690";
933    *   GlobalSetPolicyRequest globalSetPolicyRequestResource =
934    *       GlobalSetPolicyRequest.newBuilder().build();
935    *   Policy response =
936    *       instanceTemplatesClient.setIamPolicy(project, resource, globalSetPolicyRequestResource);
937    * }
938    * }</pre>
939    *
940    * @param project Project ID for this request.
941    * @param resource Name or id of the resource for this request.
942    * @param globalSetPolicyRequestResource The body resource for this request
943    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
944    */
setIamPolicy( String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)945   public final Policy setIamPolicy(
946       String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource) {
947     SetIamPolicyInstanceTemplateRequest request =
948         SetIamPolicyInstanceTemplateRequest.newBuilder()
949             .setProject(project)
950             .setResource(resource)
951             .setGlobalSetPolicyRequestResource(globalSetPolicyRequestResource)
952             .build();
953     return setIamPolicy(request);
954   }
955 
956   // AUTO-GENERATED DOCUMENTATION AND METHOD.
957   /**
958    * Sets the access control policy on the specified resource. Replaces any existing policy.
959    *
960    * <p>Sample code:
961    *
962    * <pre>{@code
963    * // This snippet has been automatically generated and should be regarded as a code template only.
964    * // It will require modifications to work:
965    * // - It may require correct/in-range values for request initialization.
966    * // - It may require specifying regional endpoints when creating the service client as shown in
967    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
968    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
969    *   SetIamPolicyInstanceTemplateRequest request =
970    *       SetIamPolicyInstanceTemplateRequest.newBuilder()
971    *           .setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build())
972    *           .setProject("project-309310695")
973    *           .setResource("resource-341064690")
974    *           .build();
975    *   Policy response = instanceTemplatesClient.setIamPolicy(request);
976    * }
977    * }</pre>
978    *
979    * @param request The request object containing all of the parameters for the API call.
980    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
981    */
setIamPolicy(SetIamPolicyInstanceTemplateRequest request)982   public final Policy setIamPolicy(SetIamPolicyInstanceTemplateRequest request) {
983     return setIamPolicyCallable().call(request);
984   }
985 
986   // AUTO-GENERATED DOCUMENTATION AND METHOD.
987   /**
988    * Sets the access control policy on the specified resource. Replaces any existing policy.
989    *
990    * <p>Sample code:
991    *
992    * <pre>{@code
993    * // This snippet has been automatically generated and should be regarded as a code template only.
994    * // It will require modifications to work:
995    * // - It may require correct/in-range values for request initialization.
996    * // - It may require specifying regional endpoints when creating the service client as shown in
997    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
998    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
999    *   SetIamPolicyInstanceTemplateRequest request =
1000    *       SetIamPolicyInstanceTemplateRequest.newBuilder()
1001    *           .setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build())
1002    *           .setProject("project-309310695")
1003    *           .setResource("resource-341064690")
1004    *           .build();
1005    *   ApiFuture<Policy> future = instanceTemplatesClient.setIamPolicyCallable().futureCall(request);
1006    *   // Do something.
1007    *   Policy response = future.get();
1008    * }
1009    * }</pre>
1010    */
setIamPolicyCallable()1011   public final UnaryCallable<SetIamPolicyInstanceTemplateRequest, Policy> setIamPolicyCallable() {
1012     return stub.setIamPolicyCallable();
1013   }
1014 
1015   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1016   /**
1017    * Returns permissions that a caller has on the specified resource.
1018    *
1019    * <p>Sample code:
1020    *
1021    * <pre>{@code
1022    * // This snippet has been automatically generated and should be regarded as a code template only.
1023    * // It will require modifications to work:
1024    * // - It may require correct/in-range values for request initialization.
1025    * // - It may require specifying regional endpoints when creating the service client as shown in
1026    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1027    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
1028    *   String project = "project-309310695";
1029    *   String resource = "resource-341064690";
1030    *   TestPermissionsRequest testPermissionsRequestResource =
1031    *       TestPermissionsRequest.newBuilder().build();
1032    *   TestPermissionsResponse response =
1033    *       instanceTemplatesClient.testIamPermissions(
1034    *           project, resource, testPermissionsRequestResource);
1035    * }
1036    * }</pre>
1037    *
1038    * @param project Project ID for this request.
1039    * @param resource Name or id of the resource for this request.
1040    * @param testPermissionsRequestResource The body resource for this request
1041    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1042    */
testIamPermissions( String project, String resource, TestPermissionsRequest testPermissionsRequestResource)1043   public final TestPermissionsResponse testIamPermissions(
1044       String project, String resource, TestPermissionsRequest testPermissionsRequestResource) {
1045     TestIamPermissionsInstanceTemplateRequest request =
1046         TestIamPermissionsInstanceTemplateRequest.newBuilder()
1047             .setProject(project)
1048             .setResource(resource)
1049             .setTestPermissionsRequestResource(testPermissionsRequestResource)
1050             .build();
1051     return testIamPermissions(request);
1052   }
1053 
1054   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1055   /**
1056    * Returns permissions that a caller has on the specified resource.
1057    *
1058    * <p>Sample code:
1059    *
1060    * <pre>{@code
1061    * // This snippet has been automatically generated and should be regarded as a code template only.
1062    * // It will require modifications to work:
1063    * // - It may require correct/in-range values for request initialization.
1064    * // - It may require specifying regional endpoints when creating the service client as shown in
1065    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1066    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
1067    *   TestIamPermissionsInstanceTemplateRequest request =
1068    *       TestIamPermissionsInstanceTemplateRequest.newBuilder()
1069    *           .setProject("project-309310695")
1070    *           .setResource("resource-341064690")
1071    *           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
1072    *           .build();
1073    *   TestPermissionsResponse response = instanceTemplatesClient.testIamPermissions(request);
1074    * }
1075    * }</pre>
1076    *
1077    * @param request The request object containing all of the parameters for the API call.
1078    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1079    */
testIamPermissions( TestIamPermissionsInstanceTemplateRequest request)1080   public final TestPermissionsResponse testIamPermissions(
1081       TestIamPermissionsInstanceTemplateRequest request) {
1082     return testIamPermissionsCallable().call(request);
1083   }
1084 
1085   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1086   /**
1087    * Returns permissions that a caller has on the specified resource.
1088    *
1089    * <p>Sample code:
1090    *
1091    * <pre>{@code
1092    * // This snippet has been automatically generated and should be regarded as a code template only.
1093    * // It will require modifications to work:
1094    * // - It may require correct/in-range values for request initialization.
1095    * // - It may require specifying regional endpoints when creating the service client as shown in
1096    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1097    * try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
1098    *   TestIamPermissionsInstanceTemplateRequest request =
1099    *       TestIamPermissionsInstanceTemplateRequest.newBuilder()
1100    *           .setProject("project-309310695")
1101    *           .setResource("resource-341064690")
1102    *           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
1103    *           .build();
1104    *   ApiFuture<TestPermissionsResponse> future =
1105    *       instanceTemplatesClient.testIamPermissionsCallable().futureCall(request);
1106    *   // Do something.
1107    *   TestPermissionsResponse response = future.get();
1108    * }
1109    * }</pre>
1110    */
1111   public final UnaryCallable<TestIamPermissionsInstanceTemplateRequest, TestPermissionsResponse>
testIamPermissionsCallable()1112       testIamPermissionsCallable() {
1113     return stub.testIamPermissionsCallable();
1114   }
1115 
1116   @Override
close()1117   public final void close() {
1118     stub.close();
1119   }
1120 
1121   @Override
shutdown()1122   public void shutdown() {
1123     stub.shutdown();
1124   }
1125 
1126   @Override
isShutdown()1127   public boolean isShutdown() {
1128     return stub.isShutdown();
1129   }
1130 
1131   @Override
isTerminated()1132   public boolean isTerminated() {
1133     return stub.isTerminated();
1134   }
1135 
1136   @Override
shutdownNow()1137   public void shutdownNow() {
1138     stub.shutdownNow();
1139   }
1140 
1141   @Override
awaitTermination(long duration, TimeUnit unit)1142   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1143     return stub.awaitTermination(duration, unit);
1144   }
1145 
1146   public static class AggregatedListPagedResponse
1147       extends AbstractPagedListResponse<
1148           AggregatedListInstanceTemplatesRequest,
1149           InstanceTemplateAggregatedList,
1150           Map.Entry<String, InstanceTemplatesScopedList>,
1151           AggregatedListPage,
1152           AggregatedListFixedSizeCollection> {
1153 
createAsync( PageContext< AggregatedListInstanceTemplatesRequest, InstanceTemplateAggregatedList, Map.Entry<String, InstanceTemplatesScopedList>> context, ApiFuture<InstanceTemplateAggregatedList> futureResponse)1154     public static ApiFuture<AggregatedListPagedResponse> createAsync(
1155         PageContext<
1156                 AggregatedListInstanceTemplatesRequest,
1157                 InstanceTemplateAggregatedList,
1158                 Map.Entry<String, InstanceTemplatesScopedList>>
1159             context,
1160         ApiFuture<InstanceTemplateAggregatedList> futureResponse) {
1161       ApiFuture<AggregatedListPage> futurePage =
1162           AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse);
1163       return ApiFutures.transform(
1164           futurePage,
1165           input -> new AggregatedListPagedResponse(input),
1166           MoreExecutors.directExecutor());
1167     }
1168 
AggregatedListPagedResponse(AggregatedListPage page)1169     private AggregatedListPagedResponse(AggregatedListPage page) {
1170       super(page, AggregatedListFixedSizeCollection.createEmptyCollection());
1171     }
1172   }
1173 
1174   public static class AggregatedListPage
1175       extends AbstractPage<
1176           AggregatedListInstanceTemplatesRequest,
1177           InstanceTemplateAggregatedList,
1178           Map.Entry<String, InstanceTemplatesScopedList>,
1179           AggregatedListPage> {
1180 
AggregatedListPage( PageContext< AggregatedListInstanceTemplatesRequest, InstanceTemplateAggregatedList, Map.Entry<String, InstanceTemplatesScopedList>> context, InstanceTemplateAggregatedList response)1181     private AggregatedListPage(
1182         PageContext<
1183                 AggregatedListInstanceTemplatesRequest,
1184                 InstanceTemplateAggregatedList,
1185                 Map.Entry<String, InstanceTemplatesScopedList>>
1186             context,
1187         InstanceTemplateAggregatedList response) {
1188       super(context, response);
1189     }
1190 
createEmptyPage()1191     private static AggregatedListPage createEmptyPage() {
1192       return new AggregatedListPage(null, null);
1193     }
1194 
1195     @Override
createPage( PageContext< AggregatedListInstanceTemplatesRequest, InstanceTemplateAggregatedList, Map.Entry<String, InstanceTemplatesScopedList>> context, InstanceTemplateAggregatedList response)1196     protected AggregatedListPage createPage(
1197         PageContext<
1198                 AggregatedListInstanceTemplatesRequest,
1199                 InstanceTemplateAggregatedList,
1200                 Map.Entry<String, InstanceTemplatesScopedList>>
1201             context,
1202         InstanceTemplateAggregatedList response) {
1203       return new AggregatedListPage(context, response);
1204     }
1205 
1206     @Override
createPageAsync( PageContext< AggregatedListInstanceTemplatesRequest, InstanceTemplateAggregatedList, Map.Entry<String, InstanceTemplatesScopedList>> context, ApiFuture<InstanceTemplateAggregatedList> futureResponse)1207     public ApiFuture<AggregatedListPage> createPageAsync(
1208         PageContext<
1209                 AggregatedListInstanceTemplatesRequest,
1210                 InstanceTemplateAggregatedList,
1211                 Map.Entry<String, InstanceTemplatesScopedList>>
1212             context,
1213         ApiFuture<InstanceTemplateAggregatedList> futureResponse) {
1214       return super.createPageAsync(context, futureResponse);
1215     }
1216   }
1217 
1218   public static class AggregatedListFixedSizeCollection
1219       extends AbstractFixedSizeCollection<
1220           AggregatedListInstanceTemplatesRequest,
1221           InstanceTemplateAggregatedList,
1222           Map.Entry<String, InstanceTemplatesScopedList>,
1223           AggregatedListPage,
1224           AggregatedListFixedSizeCollection> {
1225 
AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize)1226     private AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize) {
1227       super(pages, collectionSize);
1228     }
1229 
createEmptyCollection()1230     private static AggregatedListFixedSizeCollection createEmptyCollection() {
1231       return new AggregatedListFixedSizeCollection(null, 0);
1232     }
1233 
1234     @Override
createCollection( List<AggregatedListPage> pages, int collectionSize)1235     protected AggregatedListFixedSizeCollection createCollection(
1236         List<AggregatedListPage> pages, int collectionSize) {
1237       return new AggregatedListFixedSizeCollection(pages, collectionSize);
1238     }
1239   }
1240 
1241   public static class ListPagedResponse
1242       extends AbstractPagedListResponse<
1243           ListInstanceTemplatesRequest,
1244           InstanceTemplateList,
1245           InstanceTemplate,
1246           ListPage,
1247           ListFixedSizeCollection> {
1248 
createAsync( PageContext<ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate> context, ApiFuture<InstanceTemplateList> futureResponse)1249     public static ApiFuture<ListPagedResponse> createAsync(
1250         PageContext<ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate> context,
1251         ApiFuture<InstanceTemplateList> futureResponse) {
1252       ApiFuture<ListPage> futurePage =
1253           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
1254       return ApiFutures.transform(
1255           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
1256     }
1257 
ListPagedResponse(ListPage page)1258     private ListPagedResponse(ListPage page) {
1259       super(page, ListFixedSizeCollection.createEmptyCollection());
1260     }
1261   }
1262 
1263   public static class ListPage
1264       extends AbstractPage<
1265           ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate, ListPage> {
1266 
ListPage( PageContext<ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate> context, InstanceTemplateList response)1267     private ListPage(
1268         PageContext<ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate> context,
1269         InstanceTemplateList response) {
1270       super(context, response);
1271     }
1272 
createEmptyPage()1273     private static ListPage createEmptyPage() {
1274       return new ListPage(null, null);
1275     }
1276 
1277     @Override
createPage( PageContext<ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate> context, InstanceTemplateList response)1278     protected ListPage createPage(
1279         PageContext<ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate> context,
1280         InstanceTemplateList response) {
1281       return new ListPage(context, response);
1282     }
1283 
1284     @Override
createPageAsync( PageContext<ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate> context, ApiFuture<InstanceTemplateList> futureResponse)1285     public ApiFuture<ListPage> createPageAsync(
1286         PageContext<ListInstanceTemplatesRequest, InstanceTemplateList, InstanceTemplate> context,
1287         ApiFuture<InstanceTemplateList> futureResponse) {
1288       return super.createPageAsync(context, futureResponse);
1289     }
1290   }
1291 
1292   public static class ListFixedSizeCollection
1293       extends AbstractFixedSizeCollection<
1294           ListInstanceTemplatesRequest,
1295           InstanceTemplateList,
1296           InstanceTemplate,
1297           ListPage,
1298           ListFixedSizeCollection> {
1299 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1300     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
1301       super(pages, collectionSize);
1302     }
1303 
createEmptyCollection()1304     private static ListFixedSizeCollection createEmptyCollection() {
1305       return new ListFixedSizeCollection(null, 0);
1306     }
1307 
1308     @Override
createCollection(List<ListPage> pages, int collectionSize)1309     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
1310       return new ListFixedSizeCollection(pages, collectionSize);
1311     }
1312   }
1313 }
1314