• 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.SubnetworksStub;
31 import com.google.cloud.compute.v1.stub.SubnetworksStubSettings;
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 Subnetworks 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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
53  *   String project = "project-309310695";
54  *   String region = "region-934795532";
55  *   String subnetwork = "subnetwork-1302785042";
56  *   Subnetwork response = subnetworksClient.get(project, region, subnetwork);
57  * }
58  * }</pre>
59  *
60  * <p>Note: close() needs to be called on the SubnetworksClient object to clean up resources such as
61  * 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 SubnetworksSettings 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  * SubnetworksSettings subnetworksSettings =
95  *     SubnetworksSettings.newBuilder()
96  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
97  *         .build();
98  * SubnetworksClient subnetworksClient = SubnetworksClient.create(subnetworksSettings);
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  * SubnetworksSettings subnetworksSettings =
110  *     SubnetworksSettings.newBuilder().setEndpoint(myEndpoint).build();
111  * SubnetworksClient subnetworksClient = SubnetworksClient.create(subnetworksSettings);
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 SubnetworksClient implements BackgroundResource {
118   private final SubnetworksSettings settings;
119   private final SubnetworksStub stub;
120 
121   /** Constructs an instance of SubnetworksClient with default settings. */
create()122   public static final SubnetworksClient create() throws IOException {
123     return create(SubnetworksSettings.newBuilder().build());
124   }
125 
126   /**
127    * Constructs an instance of SubnetworksClient, using the given settings. The channels are created
128    * based on the settings passed in, or defaults for any settings that are not set.
129    */
create(SubnetworksSettings settings)130   public static final SubnetworksClient create(SubnetworksSettings settings) throws IOException {
131     return new SubnetworksClient(settings);
132   }
133 
134   /**
135    * Constructs an instance of SubnetworksClient, using the given stub for making calls. This is for
136    * advanced usage - prefer using create(SubnetworksSettings).
137    */
create(SubnetworksStub stub)138   public static final SubnetworksClient create(SubnetworksStub stub) {
139     return new SubnetworksClient(stub);
140   }
141 
142   /**
143    * Constructs an instance of SubnetworksClient, 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    */
SubnetworksClient(SubnetworksSettings settings)147   protected SubnetworksClient(SubnetworksSettings settings) throws IOException {
148     this.settings = settings;
149     this.stub = ((SubnetworksStubSettings) settings.getStubSettings()).createStub();
150   }
151 
SubnetworksClient(SubnetworksStub stub)152   protected SubnetworksClient(SubnetworksStub stub) {
153     this.settings = null;
154     this.stub = stub;
155   }
156 
getSettings()157   public final SubnetworksSettings getSettings() {
158     return settings;
159   }
160 
getStub()161   public SubnetworksStub getStub() {
162     return stub;
163   }
164 
165   // AUTO-GENERATED DOCUMENTATION AND METHOD.
166   /**
167    * Retrieves an aggregated list of subnetworks.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
178    *   String project = "project-309310695";
179    *   for (Map.Entry<String, SubnetworksScopedList> element :
180    *       subnetworksClient.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     AggregatedListSubnetworksRequest request =
191         AggregatedListSubnetworksRequest.newBuilder().setProject(project).build();
192     return aggregatedList(request);
193   }
194 
195   // AUTO-GENERATED DOCUMENTATION AND METHOD.
196   /**
197    * Retrieves an aggregated list of subnetworks.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
208    *   AggregatedListSubnetworksRequest request =
209    *       AggregatedListSubnetworksRequest.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, SubnetworksScopedList> element :
219    *       subnetworksClient.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( AggregatedListSubnetworksRequest request)228   public final AggregatedListPagedResponse aggregatedList(
229       AggregatedListSubnetworksRequest request) {
230     return aggregatedListPagedCallable().call(request);
231   }
232 
233   // AUTO-GENERATED DOCUMENTATION AND METHOD.
234   /**
235    * Retrieves an aggregated list of subnetworks.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
246    *   AggregatedListSubnetworksRequest request =
247    *       AggregatedListSubnetworksRequest.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, SubnetworksScopedList>> future =
257    *       subnetworksClient.aggregatedListPagedCallable().futureCall(request);
258    *   // Do something.
259    *   for (Map.Entry<String, SubnetworksScopedList> element : future.get().iterateAll()) {
260    *     // doThingsWith(element);
261    *   }
262    * }
263    * }</pre>
264    */
265   public final UnaryCallable<AggregatedListSubnetworksRequest, AggregatedListPagedResponse>
aggregatedListPagedCallable()266       aggregatedListPagedCallable() {
267     return stub.aggregatedListPagedCallable();
268   }
269 
270   // AUTO-GENERATED DOCUMENTATION AND METHOD.
271   /**
272    * Retrieves an aggregated list of subnetworks.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
283    *   AggregatedListSubnetworksRequest request =
284    *       AggregatedListSubnetworksRequest.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    *     SubnetworkAggregatedList response =
295    *         subnetworksClient.aggregatedListCallable().call(request);
296    *     for (Map.Entry<String, SubnetworksScopedList> 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<AggregatedListSubnetworksRequest, SubnetworkAggregatedList>
aggregatedListCallable()310       aggregatedListCallable() {
311     return stub.aggregatedListCallable();
312   }
313 
314   // AUTO-GENERATED DOCUMENTATION AND METHOD.
315   /**
316    * Deletes the specified subnetwork.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
327    *   String project = "project-309310695";
328    *   String region = "region-934795532";
329    *   String subnetwork = "subnetwork-1302785042";
330    *   Operation response = subnetworksClient.deleteAsync(project, region, subnetwork).get();
331    * }
332    * }</pre>
333    *
334    * @param project Project ID for this request.
335    * @param region Name of the region scoping this request.
336    * @param subnetwork Name of the Subnetwork resource to delete.
337    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
338    */
deleteAsync( String project, String region, String subnetwork)339   public final OperationFuture<Operation, Operation> deleteAsync(
340       String project, String region, String subnetwork) {
341     DeleteSubnetworkRequest request =
342         DeleteSubnetworkRequest.newBuilder()
343             .setProject(project)
344             .setRegion(region)
345             .setSubnetwork(subnetwork)
346             .build();
347     return deleteAsync(request);
348   }
349 
350   // AUTO-GENERATED DOCUMENTATION AND METHOD.
351   /**
352    * Deletes the specified subnetwork.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
363    *   DeleteSubnetworkRequest request =
364    *       DeleteSubnetworkRequest.newBuilder()
365    *           .setProject("project-309310695")
366    *           .setRegion("region-934795532")
367    *           .setRequestId("requestId693933066")
368    *           .setSubnetwork("subnetwork-1302785042")
369    *           .build();
370    *   Operation response = subnetworksClient.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(DeleteSubnetworkRequest request)379   public final OperationFuture<Operation, Operation> deleteAsync(DeleteSubnetworkRequest request) {
380     return deleteOperationCallable().futureCall(request);
381   }
382 
383   // AUTO-GENERATED DOCUMENTATION AND METHOD.
384   /**
385    * Deletes the specified subnetwork.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
396    *   DeleteSubnetworkRequest request =
397    *       DeleteSubnetworkRequest.newBuilder()
398    *           .setProject("project-309310695")
399    *           .setRegion("region-934795532")
400    *           .setRequestId("requestId693933066")
401    *           .setSubnetwork("subnetwork-1302785042")
402    *           .build();
403    *   OperationFuture<Operation, Operation> future =
404    *       subnetworksClient.deleteOperationCallable().futureCall(request);
405    *   // Do something.
406    *   Operation response = future.get();
407    * }
408    * }</pre>
409    */
410   public final OperationCallable<DeleteSubnetworkRequest, Operation, Operation>
deleteOperationCallable()411       deleteOperationCallable() {
412     return stub.deleteOperationCallable();
413   }
414 
415   // AUTO-GENERATED DOCUMENTATION AND METHOD.
416   /**
417    * Deletes the specified subnetwork.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
428    *   DeleteSubnetworkRequest request =
429    *       DeleteSubnetworkRequest.newBuilder()
430    *           .setProject("project-309310695")
431    *           .setRegion("region-934795532")
432    *           .setRequestId("requestId693933066")
433    *           .setSubnetwork("subnetwork-1302785042")
434    *           .build();
435    *   ApiFuture<Operation> future = subnetworksClient.deleteCallable().futureCall(request);
436    *   // Do something.
437    *   Operation response = future.get();
438    * }
439    * }</pre>
440    */
deleteCallable()441   public final UnaryCallable<DeleteSubnetworkRequest, Operation> deleteCallable() {
442     return stub.deleteCallable();
443   }
444 
445   // AUTO-GENERATED DOCUMENTATION AND METHOD.
446   /**
447    * Expands the IP CIDR range of the subnetwork to a specified value.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
458    *   String project = "project-309310695";
459    *   String region = "region-934795532";
460    *   String subnetwork = "subnetwork-1302785042";
461    *   SubnetworksExpandIpCidrRangeRequest subnetworksExpandIpCidrRangeRequestResource =
462    *       SubnetworksExpandIpCidrRangeRequest.newBuilder().build();
463    *   Operation response =
464    *       subnetworksClient
465    *           .expandIpCidrRangeAsync(
466    *               project, region, subnetwork, subnetworksExpandIpCidrRangeRequestResource)
467    *           .get();
468    * }
469    * }</pre>
470    *
471    * @param project Project ID for this request.
472    * @param region Name of the region scoping this request.
473    * @param subnetwork Name of the Subnetwork resource to update.
474    * @param subnetworksExpandIpCidrRangeRequestResource The body resource for this request
475    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
476    */
expandIpCidrRangeAsync( String project, String region, String subnetwork, SubnetworksExpandIpCidrRangeRequest subnetworksExpandIpCidrRangeRequestResource)477   public final OperationFuture<Operation, Operation> expandIpCidrRangeAsync(
478       String project,
479       String region,
480       String subnetwork,
481       SubnetworksExpandIpCidrRangeRequest subnetworksExpandIpCidrRangeRequestResource) {
482     ExpandIpCidrRangeSubnetworkRequest request =
483         ExpandIpCidrRangeSubnetworkRequest.newBuilder()
484             .setProject(project)
485             .setRegion(region)
486             .setSubnetwork(subnetwork)
487             .setSubnetworksExpandIpCidrRangeRequestResource(
488                 subnetworksExpandIpCidrRangeRequestResource)
489             .build();
490     return expandIpCidrRangeAsync(request);
491   }
492 
493   // AUTO-GENERATED DOCUMENTATION AND METHOD.
494   /**
495    * Expands the IP CIDR range of the subnetwork to a specified value.
496    *
497    * <p>Sample code:
498    *
499    * <pre>{@code
500    * // This snippet has been automatically generated and should be regarded as a code template only.
501    * // It will require modifications to work:
502    * // - It may require correct/in-range values for request initialization.
503    * // - It may require specifying regional endpoints when creating the service client as shown in
504    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
505    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
506    *   ExpandIpCidrRangeSubnetworkRequest request =
507    *       ExpandIpCidrRangeSubnetworkRequest.newBuilder()
508    *           .setProject("project-309310695")
509    *           .setRegion("region-934795532")
510    *           .setRequestId("requestId693933066")
511    *           .setSubnetwork("subnetwork-1302785042")
512    *           .setSubnetworksExpandIpCidrRangeRequestResource(
513    *               SubnetworksExpandIpCidrRangeRequest.newBuilder().build())
514    *           .build();
515    *   Operation response = subnetworksClient.expandIpCidrRangeAsync(request).get();
516    * }
517    * }</pre>
518    *
519    * @param request The request object containing all of the parameters for the API call.
520    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
521    */
522   @BetaApi(
523       "The surface for long-running operations is not stable yet and may change in the future.")
expandIpCidrRangeAsync( ExpandIpCidrRangeSubnetworkRequest request)524   public final OperationFuture<Operation, Operation> expandIpCidrRangeAsync(
525       ExpandIpCidrRangeSubnetworkRequest request) {
526     return expandIpCidrRangeOperationCallable().futureCall(request);
527   }
528 
529   // AUTO-GENERATED DOCUMENTATION AND METHOD.
530   /**
531    * Expands the IP CIDR range of the subnetwork to a specified value.
532    *
533    * <p>Sample code:
534    *
535    * <pre>{@code
536    * // This snippet has been automatically generated and should be regarded as a code template only.
537    * // It will require modifications to work:
538    * // - It may require correct/in-range values for request initialization.
539    * // - It may require specifying regional endpoints when creating the service client as shown in
540    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
541    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
542    *   ExpandIpCidrRangeSubnetworkRequest request =
543    *       ExpandIpCidrRangeSubnetworkRequest.newBuilder()
544    *           .setProject("project-309310695")
545    *           .setRegion("region-934795532")
546    *           .setRequestId("requestId693933066")
547    *           .setSubnetwork("subnetwork-1302785042")
548    *           .setSubnetworksExpandIpCidrRangeRequestResource(
549    *               SubnetworksExpandIpCidrRangeRequest.newBuilder().build())
550    *           .build();
551    *   OperationFuture<Operation, Operation> future =
552    *       subnetworksClient.expandIpCidrRangeOperationCallable().futureCall(request);
553    *   // Do something.
554    *   Operation response = future.get();
555    * }
556    * }</pre>
557    */
558   public final OperationCallable<ExpandIpCidrRangeSubnetworkRequest, Operation, Operation>
expandIpCidrRangeOperationCallable()559       expandIpCidrRangeOperationCallable() {
560     return stub.expandIpCidrRangeOperationCallable();
561   }
562 
563   // AUTO-GENERATED DOCUMENTATION AND METHOD.
564   /**
565    * Expands the IP CIDR range of the subnetwork to a specified value.
566    *
567    * <p>Sample code:
568    *
569    * <pre>{@code
570    * // This snippet has been automatically generated and should be regarded as a code template only.
571    * // It will require modifications to work:
572    * // - It may require correct/in-range values for request initialization.
573    * // - It may require specifying regional endpoints when creating the service client as shown in
574    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
575    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
576    *   ExpandIpCidrRangeSubnetworkRequest request =
577    *       ExpandIpCidrRangeSubnetworkRequest.newBuilder()
578    *           .setProject("project-309310695")
579    *           .setRegion("region-934795532")
580    *           .setRequestId("requestId693933066")
581    *           .setSubnetwork("subnetwork-1302785042")
582    *           .setSubnetworksExpandIpCidrRangeRequestResource(
583    *               SubnetworksExpandIpCidrRangeRequest.newBuilder().build())
584    *           .build();
585    *   ApiFuture<Operation> future =
586    *       subnetworksClient.expandIpCidrRangeCallable().futureCall(request);
587    *   // Do something.
588    *   Operation response = future.get();
589    * }
590    * }</pre>
591    */
592   public final UnaryCallable<ExpandIpCidrRangeSubnetworkRequest, Operation>
expandIpCidrRangeCallable()593       expandIpCidrRangeCallable() {
594     return stub.expandIpCidrRangeCallable();
595   }
596 
597   // AUTO-GENERATED DOCUMENTATION AND METHOD.
598   /**
599    * Returns the specified subnetwork.
600    *
601    * <p>Sample code:
602    *
603    * <pre>{@code
604    * // This snippet has been automatically generated and should be regarded as a code template only.
605    * // It will require modifications to work:
606    * // - It may require correct/in-range values for request initialization.
607    * // - It may require specifying regional endpoints when creating the service client as shown in
608    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
609    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
610    *   String project = "project-309310695";
611    *   String region = "region-934795532";
612    *   String subnetwork = "subnetwork-1302785042";
613    *   Subnetwork response = subnetworksClient.get(project, region, subnetwork);
614    * }
615    * }</pre>
616    *
617    * @param project Project ID for this request.
618    * @param region Name of the region scoping this request.
619    * @param subnetwork Name of the Subnetwork resource to return.
620    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
621    */
get(String project, String region, String subnetwork)622   public final Subnetwork get(String project, String region, String subnetwork) {
623     GetSubnetworkRequest request =
624         GetSubnetworkRequest.newBuilder()
625             .setProject(project)
626             .setRegion(region)
627             .setSubnetwork(subnetwork)
628             .build();
629     return get(request);
630   }
631 
632   // AUTO-GENERATED DOCUMENTATION AND METHOD.
633   /**
634    * Returns the specified subnetwork.
635    *
636    * <p>Sample code:
637    *
638    * <pre>{@code
639    * // This snippet has been automatically generated and should be regarded as a code template only.
640    * // It will require modifications to work:
641    * // - It may require correct/in-range values for request initialization.
642    * // - It may require specifying regional endpoints when creating the service client as shown in
643    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
644    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
645    *   GetSubnetworkRequest request =
646    *       GetSubnetworkRequest.newBuilder()
647    *           .setProject("project-309310695")
648    *           .setRegion("region-934795532")
649    *           .setSubnetwork("subnetwork-1302785042")
650    *           .build();
651    *   Subnetwork response = subnetworksClient.get(request);
652    * }
653    * }</pre>
654    *
655    * @param request The request object containing all of the parameters for the API call.
656    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
657    */
get(GetSubnetworkRequest request)658   public final Subnetwork get(GetSubnetworkRequest request) {
659     return getCallable().call(request);
660   }
661 
662   // AUTO-GENERATED DOCUMENTATION AND METHOD.
663   /**
664    * Returns the specified subnetwork.
665    *
666    * <p>Sample code:
667    *
668    * <pre>{@code
669    * // This snippet has been automatically generated and should be regarded as a code template only.
670    * // It will require modifications to work:
671    * // - It may require correct/in-range values for request initialization.
672    * // - It may require specifying regional endpoints when creating the service client as shown in
673    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
674    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
675    *   GetSubnetworkRequest request =
676    *       GetSubnetworkRequest.newBuilder()
677    *           .setProject("project-309310695")
678    *           .setRegion("region-934795532")
679    *           .setSubnetwork("subnetwork-1302785042")
680    *           .build();
681    *   ApiFuture<Subnetwork> future = subnetworksClient.getCallable().futureCall(request);
682    *   // Do something.
683    *   Subnetwork response = future.get();
684    * }
685    * }</pre>
686    */
getCallable()687   public final UnaryCallable<GetSubnetworkRequest, Subnetwork> getCallable() {
688     return stub.getCallable();
689   }
690 
691   // AUTO-GENERATED DOCUMENTATION AND METHOD.
692   /**
693    * Gets the access control policy for a resource. May be empty if no such policy or resource
694    * exists.
695    *
696    * <p>Sample code:
697    *
698    * <pre>{@code
699    * // This snippet has been automatically generated and should be regarded as a code template only.
700    * // It will require modifications to work:
701    * // - It may require correct/in-range values for request initialization.
702    * // - It may require specifying regional endpoints when creating the service client as shown in
703    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
704    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
705    *   String project = "project-309310695";
706    *   String region = "region-934795532";
707    *   String resource = "resource-341064690";
708    *   Policy response = subnetworksClient.getIamPolicy(project, region, resource);
709    * }
710    * }</pre>
711    *
712    * @param project Project ID for this request.
713    * @param region The name of the region for this request.
714    * @param resource Name or id of the resource for this request.
715    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
716    */
getIamPolicy(String project, String region, String resource)717   public final Policy getIamPolicy(String project, String region, String resource) {
718     GetIamPolicySubnetworkRequest request =
719         GetIamPolicySubnetworkRequest.newBuilder()
720             .setProject(project)
721             .setRegion(region)
722             .setResource(resource)
723             .build();
724     return getIamPolicy(request);
725   }
726 
727   // AUTO-GENERATED DOCUMENTATION AND METHOD.
728   /**
729    * Gets the access control policy for a resource. May be empty if no such policy or resource
730    * exists.
731    *
732    * <p>Sample code:
733    *
734    * <pre>{@code
735    * // This snippet has been automatically generated and should be regarded as a code template only.
736    * // It will require modifications to work:
737    * // - It may require correct/in-range values for request initialization.
738    * // - It may require specifying regional endpoints when creating the service client as shown in
739    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
740    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
741    *   GetIamPolicySubnetworkRequest request =
742    *       GetIamPolicySubnetworkRequest.newBuilder()
743    *           .setOptionsRequestedPolicyVersion(-574521795)
744    *           .setProject("project-309310695")
745    *           .setRegion("region-934795532")
746    *           .setResource("resource-341064690")
747    *           .build();
748    *   Policy response = subnetworksClient.getIamPolicy(request);
749    * }
750    * }</pre>
751    *
752    * @param request The request object containing all of the parameters for the API call.
753    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
754    */
getIamPolicy(GetIamPolicySubnetworkRequest request)755   public final Policy getIamPolicy(GetIamPolicySubnetworkRequest request) {
756     return getIamPolicyCallable().call(request);
757   }
758 
759   // AUTO-GENERATED DOCUMENTATION AND METHOD.
760   /**
761    * Gets the access control policy for a resource. May be empty if no such policy or resource
762    * exists.
763    *
764    * <p>Sample code:
765    *
766    * <pre>{@code
767    * // This snippet has been automatically generated and should be regarded as a code template only.
768    * // It will require modifications to work:
769    * // - It may require correct/in-range values for request initialization.
770    * // - It may require specifying regional endpoints when creating the service client as shown in
771    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
772    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
773    *   GetIamPolicySubnetworkRequest request =
774    *       GetIamPolicySubnetworkRequest.newBuilder()
775    *           .setOptionsRequestedPolicyVersion(-574521795)
776    *           .setProject("project-309310695")
777    *           .setRegion("region-934795532")
778    *           .setResource("resource-341064690")
779    *           .build();
780    *   ApiFuture<Policy> future = subnetworksClient.getIamPolicyCallable().futureCall(request);
781    *   // Do something.
782    *   Policy response = future.get();
783    * }
784    * }</pre>
785    */
getIamPolicyCallable()786   public final UnaryCallable<GetIamPolicySubnetworkRequest, Policy> getIamPolicyCallable() {
787     return stub.getIamPolicyCallable();
788   }
789 
790   // AUTO-GENERATED DOCUMENTATION AND METHOD.
791   /**
792    * Creates a subnetwork in the specified project using the data included in the request.
793    *
794    * <p>Sample code:
795    *
796    * <pre>{@code
797    * // This snippet has been automatically generated and should be regarded as a code template only.
798    * // It will require modifications to work:
799    * // - It may require correct/in-range values for request initialization.
800    * // - It may require specifying regional endpoints when creating the service client as shown in
801    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
802    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
803    *   String project = "project-309310695";
804    *   String region = "region-934795532";
805    *   Subnetwork subnetworkResource = Subnetwork.newBuilder().build();
806    *   Operation response = subnetworksClient.insertAsync(project, region, subnetworkResource).get();
807    * }
808    * }</pre>
809    *
810    * @param project Project ID for this request.
811    * @param region Name of the region scoping this request.
812    * @param subnetworkResource The body resource for this request
813    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
814    */
insertAsync( String project, String region, Subnetwork subnetworkResource)815   public final OperationFuture<Operation, Operation> insertAsync(
816       String project, String region, Subnetwork subnetworkResource) {
817     InsertSubnetworkRequest request =
818         InsertSubnetworkRequest.newBuilder()
819             .setProject(project)
820             .setRegion(region)
821             .setSubnetworkResource(subnetworkResource)
822             .build();
823     return insertAsync(request);
824   }
825 
826   // AUTO-GENERATED DOCUMENTATION AND METHOD.
827   /**
828    * Creates a subnetwork in the specified project using the data included in the request.
829    *
830    * <p>Sample code:
831    *
832    * <pre>{@code
833    * // This snippet has been automatically generated and should be regarded as a code template only.
834    * // It will require modifications to work:
835    * // - It may require correct/in-range values for request initialization.
836    * // - It may require specifying regional endpoints when creating the service client as shown in
837    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
838    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
839    *   InsertSubnetworkRequest request =
840    *       InsertSubnetworkRequest.newBuilder()
841    *           .setProject("project-309310695")
842    *           .setRegion("region-934795532")
843    *           .setRequestId("requestId693933066")
844    *           .setSubnetworkResource(Subnetwork.newBuilder().build())
845    *           .build();
846    *   Operation response = subnetworksClient.insertAsync(request).get();
847    * }
848    * }</pre>
849    *
850    * @param request The request object containing all of the parameters for the API call.
851    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
852    */
853   @BetaApi(
854       "The surface for long-running operations is not stable yet and may change in the future.")
insertAsync(InsertSubnetworkRequest request)855   public final OperationFuture<Operation, Operation> insertAsync(InsertSubnetworkRequest request) {
856     return insertOperationCallable().futureCall(request);
857   }
858 
859   // AUTO-GENERATED DOCUMENTATION AND METHOD.
860   /**
861    * Creates a subnetwork in the specified project using the data included in the request.
862    *
863    * <p>Sample code:
864    *
865    * <pre>{@code
866    * // This snippet has been automatically generated and should be regarded as a code template only.
867    * // It will require modifications to work:
868    * // - It may require correct/in-range values for request initialization.
869    * // - It may require specifying regional endpoints when creating the service client as shown in
870    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
871    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
872    *   InsertSubnetworkRequest request =
873    *       InsertSubnetworkRequest.newBuilder()
874    *           .setProject("project-309310695")
875    *           .setRegion("region-934795532")
876    *           .setRequestId("requestId693933066")
877    *           .setSubnetworkResource(Subnetwork.newBuilder().build())
878    *           .build();
879    *   OperationFuture<Operation, Operation> future =
880    *       subnetworksClient.insertOperationCallable().futureCall(request);
881    *   // Do something.
882    *   Operation response = future.get();
883    * }
884    * }</pre>
885    */
886   public final OperationCallable<InsertSubnetworkRequest, Operation, Operation>
insertOperationCallable()887       insertOperationCallable() {
888     return stub.insertOperationCallable();
889   }
890 
891   // AUTO-GENERATED DOCUMENTATION AND METHOD.
892   /**
893    * Creates a subnetwork in the specified project using the data included in the request.
894    *
895    * <p>Sample code:
896    *
897    * <pre>{@code
898    * // This snippet has been automatically generated and should be regarded as a code template only.
899    * // It will require modifications to work:
900    * // - It may require correct/in-range values for request initialization.
901    * // - It may require specifying regional endpoints when creating the service client as shown in
902    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
903    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
904    *   InsertSubnetworkRequest request =
905    *       InsertSubnetworkRequest.newBuilder()
906    *           .setProject("project-309310695")
907    *           .setRegion("region-934795532")
908    *           .setRequestId("requestId693933066")
909    *           .setSubnetworkResource(Subnetwork.newBuilder().build())
910    *           .build();
911    *   ApiFuture<Operation> future = subnetworksClient.insertCallable().futureCall(request);
912    *   // Do something.
913    *   Operation response = future.get();
914    * }
915    * }</pre>
916    */
insertCallable()917   public final UnaryCallable<InsertSubnetworkRequest, Operation> insertCallable() {
918     return stub.insertCallable();
919   }
920 
921   // AUTO-GENERATED DOCUMENTATION AND METHOD.
922   /**
923    * Retrieves a list of subnetworks available to the specified project.
924    *
925    * <p>Sample code:
926    *
927    * <pre>{@code
928    * // This snippet has been automatically generated and should be regarded as a code template only.
929    * // It will require modifications to work:
930    * // - It may require correct/in-range values for request initialization.
931    * // - It may require specifying regional endpoints when creating the service client as shown in
932    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
933    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
934    *   String project = "project-309310695";
935    *   String region = "region-934795532";
936    *   for (Subnetwork element : subnetworksClient.list(project, region).iterateAll()) {
937    *     // doThingsWith(element);
938    *   }
939    * }
940    * }</pre>
941    *
942    * @param project Project ID for this request.
943    * @param region Name of the region scoping this request.
944    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
945    */
list(String project, String region)946   public final ListPagedResponse list(String project, String region) {
947     ListSubnetworksRequest request =
948         ListSubnetworksRequest.newBuilder().setProject(project).setRegion(region).build();
949     return list(request);
950   }
951 
952   // AUTO-GENERATED DOCUMENTATION AND METHOD.
953   /**
954    * Retrieves a list of subnetworks available to the specified project.
955    *
956    * <p>Sample code:
957    *
958    * <pre>{@code
959    * // This snippet has been automatically generated and should be regarded as a code template only.
960    * // It will require modifications to work:
961    * // - It may require correct/in-range values for request initialization.
962    * // - It may require specifying regional endpoints when creating the service client as shown in
963    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
964    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
965    *   ListSubnetworksRequest request =
966    *       ListSubnetworksRequest.newBuilder()
967    *           .setFilter("filter-1274492040")
968    *           .setMaxResults(1128457243)
969    *           .setOrderBy("orderBy-1207110587")
970    *           .setPageToken("pageToken873572522")
971    *           .setProject("project-309310695")
972    *           .setRegion("region-934795532")
973    *           .setReturnPartialSuccess(true)
974    *           .build();
975    *   for (Subnetwork element : subnetworksClient.list(request).iterateAll()) {
976    *     // doThingsWith(element);
977    *   }
978    * }
979    * }</pre>
980    *
981    * @param request The request object containing all of the parameters for the API call.
982    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
983    */
list(ListSubnetworksRequest request)984   public final ListPagedResponse list(ListSubnetworksRequest request) {
985     return listPagedCallable().call(request);
986   }
987 
988   // AUTO-GENERATED DOCUMENTATION AND METHOD.
989   /**
990    * Retrieves a list of subnetworks available to the specified project.
991    *
992    * <p>Sample code:
993    *
994    * <pre>{@code
995    * // This snippet has been automatically generated and should be regarded as a code template only.
996    * // It will require modifications to work:
997    * // - It may require correct/in-range values for request initialization.
998    * // - It may require specifying regional endpoints when creating the service client as shown in
999    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1000    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1001    *   ListSubnetworksRequest request =
1002    *       ListSubnetworksRequest.newBuilder()
1003    *           .setFilter("filter-1274492040")
1004    *           .setMaxResults(1128457243)
1005    *           .setOrderBy("orderBy-1207110587")
1006    *           .setPageToken("pageToken873572522")
1007    *           .setProject("project-309310695")
1008    *           .setRegion("region-934795532")
1009    *           .setReturnPartialSuccess(true)
1010    *           .build();
1011    *   ApiFuture<Subnetwork> future = subnetworksClient.listPagedCallable().futureCall(request);
1012    *   // Do something.
1013    *   for (Subnetwork element : future.get().iterateAll()) {
1014    *     // doThingsWith(element);
1015    *   }
1016    * }
1017    * }</pre>
1018    */
listPagedCallable()1019   public final UnaryCallable<ListSubnetworksRequest, ListPagedResponse> listPagedCallable() {
1020     return stub.listPagedCallable();
1021   }
1022 
1023   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1024   /**
1025    * Retrieves a list of subnetworks available to the specified project.
1026    *
1027    * <p>Sample code:
1028    *
1029    * <pre>{@code
1030    * // This snippet has been automatically generated and should be regarded as a code template only.
1031    * // It will require modifications to work:
1032    * // - It may require correct/in-range values for request initialization.
1033    * // - It may require specifying regional endpoints when creating the service client as shown in
1034    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1035    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1036    *   ListSubnetworksRequest request =
1037    *       ListSubnetworksRequest.newBuilder()
1038    *           .setFilter("filter-1274492040")
1039    *           .setMaxResults(1128457243)
1040    *           .setOrderBy("orderBy-1207110587")
1041    *           .setPageToken("pageToken873572522")
1042    *           .setProject("project-309310695")
1043    *           .setRegion("region-934795532")
1044    *           .setReturnPartialSuccess(true)
1045    *           .build();
1046    *   while (true) {
1047    *     SubnetworkList response = subnetworksClient.listCallable().call(request);
1048    *     for (Subnetwork element : response.getItemsList()) {
1049    *       // doThingsWith(element);
1050    *     }
1051    *     String nextPageToken = response.getNextPageToken();
1052    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
1053    *       request = request.toBuilder().setPageToken(nextPageToken).build();
1054    *     } else {
1055    *       break;
1056    *     }
1057    *   }
1058    * }
1059    * }</pre>
1060    */
listCallable()1061   public final UnaryCallable<ListSubnetworksRequest, SubnetworkList> listCallable() {
1062     return stub.listCallable();
1063   }
1064 
1065   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1066   /**
1067    * Retrieves an aggregated list of all usable subnetworks in the project.
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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1078    *   String project = "project-309310695";
1079    *   for (UsableSubnetwork element : subnetworksClient.listUsable(project).iterateAll()) {
1080    *     // doThingsWith(element);
1081    *   }
1082    * }
1083    * }</pre>
1084    *
1085    * @param project Project ID for this request.
1086    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1087    */
listUsable(String project)1088   public final ListUsablePagedResponse listUsable(String project) {
1089     ListUsableSubnetworksRequest request =
1090         ListUsableSubnetworksRequest.newBuilder().setProject(project).build();
1091     return listUsable(request);
1092   }
1093 
1094   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1095   /**
1096    * Retrieves an aggregated list of all usable subnetworks in the project.
1097    *
1098    * <p>Sample code:
1099    *
1100    * <pre>{@code
1101    * // This snippet has been automatically generated and should be regarded as a code template only.
1102    * // It will require modifications to work:
1103    * // - It may require correct/in-range values for request initialization.
1104    * // - It may require specifying regional endpoints when creating the service client as shown in
1105    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1106    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1107    *   ListUsableSubnetworksRequest request =
1108    *       ListUsableSubnetworksRequest.newBuilder()
1109    *           .setFilter("filter-1274492040")
1110    *           .setMaxResults(1128457243)
1111    *           .setOrderBy("orderBy-1207110587")
1112    *           .setPageToken("pageToken873572522")
1113    *           .setProject("project-309310695")
1114    *           .setReturnPartialSuccess(true)
1115    *           .build();
1116    *   for (UsableSubnetwork element : subnetworksClient.listUsable(request).iterateAll()) {
1117    *     // doThingsWith(element);
1118    *   }
1119    * }
1120    * }</pre>
1121    *
1122    * @param request The request object containing all of the parameters for the API call.
1123    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1124    */
listUsable(ListUsableSubnetworksRequest request)1125   public final ListUsablePagedResponse listUsable(ListUsableSubnetworksRequest request) {
1126     return listUsablePagedCallable().call(request);
1127   }
1128 
1129   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1130   /**
1131    * Retrieves an aggregated list of all usable subnetworks in the project.
1132    *
1133    * <p>Sample code:
1134    *
1135    * <pre>{@code
1136    * // This snippet has been automatically generated and should be regarded as a code template only.
1137    * // It will require modifications to work:
1138    * // - It may require correct/in-range values for request initialization.
1139    * // - It may require specifying regional endpoints when creating the service client as shown in
1140    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1141    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1142    *   ListUsableSubnetworksRequest request =
1143    *       ListUsableSubnetworksRequest.newBuilder()
1144    *           .setFilter("filter-1274492040")
1145    *           .setMaxResults(1128457243)
1146    *           .setOrderBy("orderBy-1207110587")
1147    *           .setPageToken("pageToken873572522")
1148    *           .setProject("project-309310695")
1149    *           .setReturnPartialSuccess(true)
1150    *           .build();
1151    *   ApiFuture<UsableSubnetwork> future =
1152    *       subnetworksClient.listUsablePagedCallable().futureCall(request);
1153    *   // Do something.
1154    *   for (UsableSubnetwork element : future.get().iterateAll()) {
1155    *     // doThingsWith(element);
1156    *   }
1157    * }
1158    * }</pre>
1159    */
1160   public final UnaryCallable<ListUsableSubnetworksRequest, ListUsablePagedResponse>
listUsablePagedCallable()1161       listUsablePagedCallable() {
1162     return stub.listUsablePagedCallable();
1163   }
1164 
1165   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1166   /**
1167    * Retrieves an aggregated list of all usable subnetworks in the project.
1168    *
1169    * <p>Sample code:
1170    *
1171    * <pre>{@code
1172    * // This snippet has been automatically generated and should be regarded as a code template only.
1173    * // It will require modifications to work:
1174    * // - It may require correct/in-range values for request initialization.
1175    * // - It may require specifying regional endpoints when creating the service client as shown in
1176    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1177    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1178    *   ListUsableSubnetworksRequest request =
1179    *       ListUsableSubnetworksRequest.newBuilder()
1180    *           .setFilter("filter-1274492040")
1181    *           .setMaxResults(1128457243)
1182    *           .setOrderBy("orderBy-1207110587")
1183    *           .setPageToken("pageToken873572522")
1184    *           .setProject("project-309310695")
1185    *           .setReturnPartialSuccess(true)
1186    *           .build();
1187    *   while (true) {
1188    *     UsableSubnetworksAggregatedList response =
1189    *         subnetworksClient.listUsableCallable().call(request);
1190    *     for (UsableSubnetwork element : response.getItemsList()) {
1191    *       // doThingsWith(element);
1192    *     }
1193    *     String nextPageToken = response.getNextPageToken();
1194    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
1195    *       request = request.toBuilder().setPageToken(nextPageToken).build();
1196    *     } else {
1197    *       break;
1198    *     }
1199    *   }
1200    * }
1201    * }</pre>
1202    */
1203   public final UnaryCallable<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList>
listUsableCallable()1204       listUsableCallable() {
1205     return stub.listUsableCallable();
1206   }
1207 
1208   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1209   /**
1210    * Patches the specified subnetwork with the data included in the request. Only certain fields can
1211    * be updated with a patch request as indicated in the field descriptions. You must specify the
1212    * current fingerprint of the subnetwork resource being patched.
1213    *
1214    * <p>Sample code:
1215    *
1216    * <pre>{@code
1217    * // This snippet has been automatically generated and should be regarded as a code template only.
1218    * // It will require modifications to work:
1219    * // - It may require correct/in-range values for request initialization.
1220    * // - It may require specifying regional endpoints when creating the service client as shown in
1221    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1222    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1223    *   String project = "project-309310695";
1224    *   String region = "region-934795532";
1225    *   String subnetwork = "subnetwork-1302785042";
1226    *   Subnetwork subnetworkResource = Subnetwork.newBuilder().build();
1227    *   Operation response =
1228    *       subnetworksClient.patchAsync(project, region, subnetwork, subnetworkResource).get();
1229    * }
1230    * }</pre>
1231    *
1232    * @param project Project ID for this request.
1233    * @param region Name of the region scoping this request.
1234    * @param subnetwork Name of the Subnetwork resource to patch.
1235    * @param subnetworkResource The body resource for this request
1236    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1237    */
patchAsync( String project, String region, String subnetwork, Subnetwork subnetworkResource)1238   public final OperationFuture<Operation, Operation> patchAsync(
1239       String project, String region, String subnetwork, Subnetwork subnetworkResource) {
1240     PatchSubnetworkRequest request =
1241         PatchSubnetworkRequest.newBuilder()
1242             .setProject(project)
1243             .setRegion(region)
1244             .setSubnetwork(subnetwork)
1245             .setSubnetworkResource(subnetworkResource)
1246             .build();
1247     return patchAsync(request);
1248   }
1249 
1250   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1251   /**
1252    * Patches the specified subnetwork with the data included in the request. Only certain fields can
1253    * be updated with a patch request as indicated in the field descriptions. You must specify the
1254    * current fingerprint of the subnetwork resource being patched.
1255    *
1256    * <p>Sample code:
1257    *
1258    * <pre>{@code
1259    * // This snippet has been automatically generated and should be regarded as a code template only.
1260    * // It will require modifications to work:
1261    * // - It may require correct/in-range values for request initialization.
1262    * // - It may require specifying regional endpoints when creating the service client as shown in
1263    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1264    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1265    *   PatchSubnetworkRequest request =
1266    *       PatchSubnetworkRequest.newBuilder()
1267    *           .setDrainTimeoutSeconds(1431448922)
1268    *           .setProject("project-309310695")
1269    *           .setRegion("region-934795532")
1270    *           .setRequestId("requestId693933066")
1271    *           .setSubnetwork("subnetwork-1302785042")
1272    *           .setSubnetworkResource(Subnetwork.newBuilder().build())
1273    *           .build();
1274    *   Operation response = subnetworksClient.patchAsync(request).get();
1275    * }
1276    * }</pre>
1277    *
1278    * @param request The request object containing all of the parameters for the API call.
1279    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1280    */
1281   @BetaApi(
1282       "The surface for long-running operations is not stable yet and may change in the future.")
patchAsync(PatchSubnetworkRequest request)1283   public final OperationFuture<Operation, Operation> patchAsync(PatchSubnetworkRequest request) {
1284     return patchOperationCallable().futureCall(request);
1285   }
1286 
1287   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1288   /**
1289    * Patches the specified subnetwork with the data included in the request. Only certain fields can
1290    * be updated with a patch request as indicated in the field descriptions. You must specify the
1291    * current fingerprint of the subnetwork resource being patched.
1292    *
1293    * <p>Sample code:
1294    *
1295    * <pre>{@code
1296    * // This snippet has been automatically generated and should be regarded as a code template only.
1297    * // It will require modifications to work:
1298    * // - It may require correct/in-range values for request initialization.
1299    * // - It may require specifying regional endpoints when creating the service client as shown in
1300    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1301    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1302    *   PatchSubnetworkRequest request =
1303    *       PatchSubnetworkRequest.newBuilder()
1304    *           .setDrainTimeoutSeconds(1431448922)
1305    *           .setProject("project-309310695")
1306    *           .setRegion("region-934795532")
1307    *           .setRequestId("requestId693933066")
1308    *           .setSubnetwork("subnetwork-1302785042")
1309    *           .setSubnetworkResource(Subnetwork.newBuilder().build())
1310    *           .build();
1311    *   OperationFuture<Operation, Operation> future =
1312    *       subnetworksClient.patchOperationCallable().futureCall(request);
1313    *   // Do something.
1314    *   Operation response = future.get();
1315    * }
1316    * }</pre>
1317    */
1318   public final OperationCallable<PatchSubnetworkRequest, Operation, Operation>
patchOperationCallable()1319       patchOperationCallable() {
1320     return stub.patchOperationCallable();
1321   }
1322 
1323   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1324   /**
1325    * Patches the specified subnetwork with the data included in the request. Only certain fields can
1326    * be updated with a patch request as indicated in the field descriptions. You must specify the
1327    * current fingerprint of the subnetwork resource being patched.
1328    *
1329    * <p>Sample code:
1330    *
1331    * <pre>{@code
1332    * // This snippet has been automatically generated and should be regarded as a code template only.
1333    * // It will require modifications to work:
1334    * // - It may require correct/in-range values for request initialization.
1335    * // - It may require specifying regional endpoints when creating the service client as shown in
1336    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1337    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1338    *   PatchSubnetworkRequest request =
1339    *       PatchSubnetworkRequest.newBuilder()
1340    *           .setDrainTimeoutSeconds(1431448922)
1341    *           .setProject("project-309310695")
1342    *           .setRegion("region-934795532")
1343    *           .setRequestId("requestId693933066")
1344    *           .setSubnetwork("subnetwork-1302785042")
1345    *           .setSubnetworkResource(Subnetwork.newBuilder().build())
1346    *           .build();
1347    *   ApiFuture<Operation> future = subnetworksClient.patchCallable().futureCall(request);
1348    *   // Do something.
1349    *   Operation response = future.get();
1350    * }
1351    * }</pre>
1352    */
patchCallable()1353   public final UnaryCallable<PatchSubnetworkRequest, Operation> patchCallable() {
1354     return stub.patchCallable();
1355   }
1356 
1357   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1358   /**
1359    * Sets the access control policy on the specified resource. Replaces any existing policy.
1360    *
1361    * <p>Sample code:
1362    *
1363    * <pre>{@code
1364    * // This snippet has been automatically generated and should be regarded as a code template only.
1365    * // It will require modifications to work:
1366    * // - It may require correct/in-range values for request initialization.
1367    * // - It may require specifying regional endpoints when creating the service client as shown in
1368    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1369    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1370    *   String project = "project-309310695";
1371    *   String region = "region-934795532";
1372    *   String resource = "resource-341064690";
1373    *   RegionSetPolicyRequest regionSetPolicyRequestResource =
1374    *       RegionSetPolicyRequest.newBuilder().build();
1375    *   Policy response =
1376    *       subnetworksClient.setIamPolicy(project, region, resource, regionSetPolicyRequestResource);
1377    * }
1378    * }</pre>
1379    *
1380    * @param project Project ID for this request.
1381    * @param region The name of the region for this request.
1382    * @param resource Name or id of the resource for this request.
1383    * @param regionSetPolicyRequestResource The body resource for this request
1384    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1385    */
setIamPolicy( String project, String region, String resource, RegionSetPolicyRequest regionSetPolicyRequestResource)1386   public final Policy setIamPolicy(
1387       String project,
1388       String region,
1389       String resource,
1390       RegionSetPolicyRequest regionSetPolicyRequestResource) {
1391     SetIamPolicySubnetworkRequest request =
1392         SetIamPolicySubnetworkRequest.newBuilder()
1393             .setProject(project)
1394             .setRegion(region)
1395             .setResource(resource)
1396             .setRegionSetPolicyRequestResource(regionSetPolicyRequestResource)
1397             .build();
1398     return setIamPolicy(request);
1399   }
1400 
1401   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1402   /**
1403    * Sets the access control policy on the specified resource. Replaces any existing policy.
1404    *
1405    * <p>Sample code:
1406    *
1407    * <pre>{@code
1408    * // This snippet has been automatically generated and should be regarded as a code template only.
1409    * // It will require modifications to work:
1410    * // - It may require correct/in-range values for request initialization.
1411    * // - It may require specifying regional endpoints when creating the service client as shown in
1412    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1413    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1414    *   SetIamPolicySubnetworkRequest request =
1415    *       SetIamPolicySubnetworkRequest.newBuilder()
1416    *           .setProject("project-309310695")
1417    *           .setRegion("region-934795532")
1418    *           .setRegionSetPolicyRequestResource(RegionSetPolicyRequest.newBuilder().build())
1419    *           .setResource("resource-341064690")
1420    *           .build();
1421    *   Policy response = subnetworksClient.setIamPolicy(request);
1422    * }
1423    * }</pre>
1424    *
1425    * @param request The request object containing all of the parameters for the API call.
1426    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1427    */
setIamPolicy(SetIamPolicySubnetworkRequest request)1428   public final Policy setIamPolicy(SetIamPolicySubnetworkRequest request) {
1429     return setIamPolicyCallable().call(request);
1430   }
1431 
1432   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1433   /**
1434    * Sets the access control policy on the specified resource. Replaces any existing policy.
1435    *
1436    * <p>Sample code:
1437    *
1438    * <pre>{@code
1439    * // This snippet has been automatically generated and should be regarded as a code template only.
1440    * // It will require modifications to work:
1441    * // - It may require correct/in-range values for request initialization.
1442    * // - It may require specifying regional endpoints when creating the service client as shown in
1443    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1444    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1445    *   SetIamPolicySubnetworkRequest request =
1446    *       SetIamPolicySubnetworkRequest.newBuilder()
1447    *           .setProject("project-309310695")
1448    *           .setRegion("region-934795532")
1449    *           .setRegionSetPolicyRequestResource(RegionSetPolicyRequest.newBuilder().build())
1450    *           .setResource("resource-341064690")
1451    *           .build();
1452    *   ApiFuture<Policy> future = subnetworksClient.setIamPolicyCallable().futureCall(request);
1453    *   // Do something.
1454    *   Policy response = future.get();
1455    * }
1456    * }</pre>
1457    */
setIamPolicyCallable()1458   public final UnaryCallable<SetIamPolicySubnetworkRequest, Policy> setIamPolicyCallable() {
1459     return stub.setIamPolicyCallable();
1460   }
1461 
1462   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1463   /**
1464    * Set whether VMs in this subnet can access Google services without assigning external IP
1465    * addresses through Private Google Access.
1466    *
1467    * <p>Sample code:
1468    *
1469    * <pre>{@code
1470    * // This snippet has been automatically generated and should be regarded as a code template only.
1471    * // It will require modifications to work:
1472    * // - It may require correct/in-range values for request initialization.
1473    * // - It may require specifying regional endpoints when creating the service client as shown in
1474    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1475    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1476    *   String project = "project-309310695";
1477    *   String region = "region-934795532";
1478    *   String subnetwork = "subnetwork-1302785042";
1479    *   SubnetworksSetPrivateIpGoogleAccessRequest
1480    *       subnetworksSetPrivateIpGoogleAccessRequestResource =
1481    *           SubnetworksSetPrivateIpGoogleAccessRequest.newBuilder().build();
1482    *   Operation response =
1483    *       subnetworksClient
1484    *           .setPrivateIpGoogleAccessAsync(
1485    *               project, region, subnetwork, subnetworksSetPrivateIpGoogleAccessRequestResource)
1486    *           .get();
1487    * }
1488    * }</pre>
1489    *
1490    * @param project Project ID for this request.
1491    * @param region Name of the region scoping this request.
1492    * @param subnetwork Name of the Subnetwork resource.
1493    * @param subnetworksSetPrivateIpGoogleAccessRequestResource The body resource for this request
1494    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1495    */
setPrivateIpGoogleAccessAsync( String project, String region, String subnetwork, SubnetworksSetPrivateIpGoogleAccessRequest subnetworksSetPrivateIpGoogleAccessRequestResource)1496   public final OperationFuture<Operation, Operation> setPrivateIpGoogleAccessAsync(
1497       String project,
1498       String region,
1499       String subnetwork,
1500       SubnetworksSetPrivateIpGoogleAccessRequest
1501           subnetworksSetPrivateIpGoogleAccessRequestResource) {
1502     SetPrivateIpGoogleAccessSubnetworkRequest request =
1503         SetPrivateIpGoogleAccessSubnetworkRequest.newBuilder()
1504             .setProject(project)
1505             .setRegion(region)
1506             .setSubnetwork(subnetwork)
1507             .setSubnetworksSetPrivateIpGoogleAccessRequestResource(
1508                 subnetworksSetPrivateIpGoogleAccessRequestResource)
1509             .build();
1510     return setPrivateIpGoogleAccessAsync(request);
1511   }
1512 
1513   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1514   /**
1515    * Set whether VMs in this subnet can access Google services without assigning external IP
1516    * addresses through Private Google Access.
1517    *
1518    * <p>Sample code:
1519    *
1520    * <pre>{@code
1521    * // This snippet has been automatically generated and should be regarded as a code template only.
1522    * // It will require modifications to work:
1523    * // - It may require correct/in-range values for request initialization.
1524    * // - It may require specifying regional endpoints when creating the service client as shown in
1525    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1526    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1527    *   SetPrivateIpGoogleAccessSubnetworkRequest request =
1528    *       SetPrivateIpGoogleAccessSubnetworkRequest.newBuilder()
1529    *           .setProject("project-309310695")
1530    *           .setRegion("region-934795532")
1531    *           .setRequestId("requestId693933066")
1532    *           .setSubnetwork("subnetwork-1302785042")
1533    *           .setSubnetworksSetPrivateIpGoogleAccessRequestResource(
1534    *               SubnetworksSetPrivateIpGoogleAccessRequest.newBuilder().build())
1535    *           .build();
1536    *   Operation response = subnetworksClient.setPrivateIpGoogleAccessAsync(request).get();
1537    * }
1538    * }</pre>
1539    *
1540    * @param request The request object containing all of the parameters for the API call.
1541    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1542    */
1543   @BetaApi(
1544       "The surface for long-running operations is not stable yet and may change in the future.")
setPrivateIpGoogleAccessAsync( SetPrivateIpGoogleAccessSubnetworkRequest request)1545   public final OperationFuture<Operation, Operation> setPrivateIpGoogleAccessAsync(
1546       SetPrivateIpGoogleAccessSubnetworkRequest request) {
1547     return setPrivateIpGoogleAccessOperationCallable().futureCall(request);
1548   }
1549 
1550   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1551   /**
1552    * Set whether VMs in this subnet can access Google services without assigning external IP
1553    * addresses through Private Google Access.
1554    *
1555    * <p>Sample code:
1556    *
1557    * <pre>{@code
1558    * // This snippet has been automatically generated and should be regarded as a code template only.
1559    * // It will require modifications to work:
1560    * // - It may require correct/in-range values for request initialization.
1561    * // - It may require specifying regional endpoints when creating the service client as shown in
1562    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1563    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1564    *   SetPrivateIpGoogleAccessSubnetworkRequest request =
1565    *       SetPrivateIpGoogleAccessSubnetworkRequest.newBuilder()
1566    *           .setProject("project-309310695")
1567    *           .setRegion("region-934795532")
1568    *           .setRequestId("requestId693933066")
1569    *           .setSubnetwork("subnetwork-1302785042")
1570    *           .setSubnetworksSetPrivateIpGoogleAccessRequestResource(
1571    *               SubnetworksSetPrivateIpGoogleAccessRequest.newBuilder().build())
1572    *           .build();
1573    *   OperationFuture<Operation, Operation> future =
1574    *       subnetworksClient.setPrivateIpGoogleAccessOperationCallable().futureCall(request);
1575    *   // Do something.
1576    *   Operation response = future.get();
1577    * }
1578    * }</pre>
1579    */
1580   public final OperationCallable<SetPrivateIpGoogleAccessSubnetworkRequest, Operation, Operation>
setPrivateIpGoogleAccessOperationCallable()1581       setPrivateIpGoogleAccessOperationCallable() {
1582     return stub.setPrivateIpGoogleAccessOperationCallable();
1583   }
1584 
1585   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1586   /**
1587    * Set whether VMs in this subnet can access Google services without assigning external IP
1588    * addresses through Private Google Access.
1589    *
1590    * <p>Sample code:
1591    *
1592    * <pre>{@code
1593    * // This snippet has been automatically generated and should be regarded as a code template only.
1594    * // It will require modifications to work:
1595    * // - It may require correct/in-range values for request initialization.
1596    * // - It may require specifying regional endpoints when creating the service client as shown in
1597    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1598    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1599    *   SetPrivateIpGoogleAccessSubnetworkRequest request =
1600    *       SetPrivateIpGoogleAccessSubnetworkRequest.newBuilder()
1601    *           .setProject("project-309310695")
1602    *           .setRegion("region-934795532")
1603    *           .setRequestId("requestId693933066")
1604    *           .setSubnetwork("subnetwork-1302785042")
1605    *           .setSubnetworksSetPrivateIpGoogleAccessRequestResource(
1606    *               SubnetworksSetPrivateIpGoogleAccessRequest.newBuilder().build())
1607    *           .build();
1608    *   ApiFuture<Operation> future =
1609    *       subnetworksClient.setPrivateIpGoogleAccessCallable().futureCall(request);
1610    *   // Do something.
1611    *   Operation response = future.get();
1612    * }
1613    * }</pre>
1614    */
1615   public final UnaryCallable<SetPrivateIpGoogleAccessSubnetworkRequest, Operation>
setPrivateIpGoogleAccessCallable()1616       setPrivateIpGoogleAccessCallable() {
1617     return stub.setPrivateIpGoogleAccessCallable();
1618   }
1619 
1620   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1621   /**
1622    * Returns permissions that a caller has on the specified resource.
1623    *
1624    * <p>Sample code:
1625    *
1626    * <pre>{@code
1627    * // This snippet has been automatically generated and should be regarded as a code template only.
1628    * // It will require modifications to work:
1629    * // - It may require correct/in-range values for request initialization.
1630    * // - It may require specifying regional endpoints when creating the service client as shown in
1631    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1632    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1633    *   String project = "project-309310695";
1634    *   String region = "region-934795532";
1635    *   String resource = "resource-341064690";
1636    *   TestPermissionsRequest testPermissionsRequestResource =
1637    *       TestPermissionsRequest.newBuilder().build();
1638    *   TestPermissionsResponse response =
1639    *       subnetworksClient.testIamPermissions(
1640    *           project, region, resource, testPermissionsRequestResource);
1641    * }
1642    * }</pre>
1643    *
1644    * @param project Project ID for this request.
1645    * @param region The name of the region for this request.
1646    * @param resource Name or id of the resource for this request.
1647    * @param testPermissionsRequestResource The body resource for this request
1648    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1649    */
testIamPermissions( String project, String region, String resource, TestPermissionsRequest testPermissionsRequestResource)1650   public final TestPermissionsResponse testIamPermissions(
1651       String project,
1652       String region,
1653       String resource,
1654       TestPermissionsRequest testPermissionsRequestResource) {
1655     TestIamPermissionsSubnetworkRequest request =
1656         TestIamPermissionsSubnetworkRequest.newBuilder()
1657             .setProject(project)
1658             .setRegion(region)
1659             .setResource(resource)
1660             .setTestPermissionsRequestResource(testPermissionsRequestResource)
1661             .build();
1662     return testIamPermissions(request);
1663   }
1664 
1665   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1666   /**
1667    * Returns permissions that a caller has on the specified resource.
1668    *
1669    * <p>Sample code:
1670    *
1671    * <pre>{@code
1672    * // This snippet has been automatically generated and should be regarded as a code template only.
1673    * // It will require modifications to work:
1674    * // - It may require correct/in-range values for request initialization.
1675    * // - It may require specifying regional endpoints when creating the service client as shown in
1676    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1677    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1678    *   TestIamPermissionsSubnetworkRequest request =
1679    *       TestIamPermissionsSubnetworkRequest.newBuilder()
1680    *           .setProject("project-309310695")
1681    *           .setRegion("region-934795532")
1682    *           .setResource("resource-341064690")
1683    *           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
1684    *           .build();
1685    *   TestPermissionsResponse response = subnetworksClient.testIamPermissions(request);
1686    * }
1687    * }</pre>
1688    *
1689    * @param request The request object containing all of the parameters for the API call.
1690    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1691    */
testIamPermissions( TestIamPermissionsSubnetworkRequest request)1692   public final TestPermissionsResponse testIamPermissions(
1693       TestIamPermissionsSubnetworkRequest request) {
1694     return testIamPermissionsCallable().call(request);
1695   }
1696 
1697   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1698   /**
1699    * Returns permissions that a caller has on the specified resource.
1700    *
1701    * <p>Sample code:
1702    *
1703    * <pre>{@code
1704    * // This snippet has been automatically generated and should be regarded as a code template only.
1705    * // It will require modifications to work:
1706    * // - It may require correct/in-range values for request initialization.
1707    * // - It may require specifying regional endpoints when creating the service client as shown in
1708    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1709    * try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
1710    *   TestIamPermissionsSubnetworkRequest request =
1711    *       TestIamPermissionsSubnetworkRequest.newBuilder()
1712    *           .setProject("project-309310695")
1713    *           .setRegion("region-934795532")
1714    *           .setResource("resource-341064690")
1715    *           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
1716    *           .build();
1717    *   ApiFuture<TestPermissionsResponse> future =
1718    *       subnetworksClient.testIamPermissionsCallable().futureCall(request);
1719    *   // Do something.
1720    *   TestPermissionsResponse response = future.get();
1721    * }
1722    * }</pre>
1723    */
1724   public final UnaryCallable<TestIamPermissionsSubnetworkRequest, TestPermissionsResponse>
testIamPermissionsCallable()1725       testIamPermissionsCallable() {
1726     return stub.testIamPermissionsCallable();
1727   }
1728 
1729   @Override
close()1730   public final void close() {
1731     stub.close();
1732   }
1733 
1734   @Override
shutdown()1735   public void shutdown() {
1736     stub.shutdown();
1737   }
1738 
1739   @Override
isShutdown()1740   public boolean isShutdown() {
1741     return stub.isShutdown();
1742   }
1743 
1744   @Override
isTerminated()1745   public boolean isTerminated() {
1746     return stub.isTerminated();
1747   }
1748 
1749   @Override
shutdownNow()1750   public void shutdownNow() {
1751     stub.shutdownNow();
1752   }
1753 
1754   @Override
awaitTermination(long duration, TimeUnit unit)1755   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1756     return stub.awaitTermination(duration, unit);
1757   }
1758 
1759   public static class AggregatedListPagedResponse
1760       extends AbstractPagedListResponse<
1761           AggregatedListSubnetworksRequest,
1762           SubnetworkAggregatedList,
1763           Map.Entry<String, SubnetworksScopedList>,
1764           AggregatedListPage,
1765           AggregatedListFixedSizeCollection> {
1766 
createAsync( PageContext< AggregatedListSubnetworksRequest, SubnetworkAggregatedList, Map.Entry<String, SubnetworksScopedList>> context, ApiFuture<SubnetworkAggregatedList> futureResponse)1767     public static ApiFuture<AggregatedListPagedResponse> createAsync(
1768         PageContext<
1769                 AggregatedListSubnetworksRequest,
1770                 SubnetworkAggregatedList,
1771                 Map.Entry<String, SubnetworksScopedList>>
1772             context,
1773         ApiFuture<SubnetworkAggregatedList> futureResponse) {
1774       ApiFuture<AggregatedListPage> futurePage =
1775           AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse);
1776       return ApiFutures.transform(
1777           futurePage,
1778           input -> new AggregatedListPagedResponse(input),
1779           MoreExecutors.directExecutor());
1780     }
1781 
AggregatedListPagedResponse(AggregatedListPage page)1782     private AggregatedListPagedResponse(AggregatedListPage page) {
1783       super(page, AggregatedListFixedSizeCollection.createEmptyCollection());
1784     }
1785   }
1786 
1787   public static class AggregatedListPage
1788       extends AbstractPage<
1789           AggregatedListSubnetworksRequest,
1790           SubnetworkAggregatedList,
1791           Map.Entry<String, SubnetworksScopedList>,
1792           AggregatedListPage> {
1793 
AggregatedListPage( PageContext< AggregatedListSubnetworksRequest, SubnetworkAggregatedList, Map.Entry<String, SubnetworksScopedList>> context, SubnetworkAggregatedList response)1794     private AggregatedListPage(
1795         PageContext<
1796                 AggregatedListSubnetworksRequest,
1797                 SubnetworkAggregatedList,
1798                 Map.Entry<String, SubnetworksScopedList>>
1799             context,
1800         SubnetworkAggregatedList response) {
1801       super(context, response);
1802     }
1803 
createEmptyPage()1804     private static AggregatedListPage createEmptyPage() {
1805       return new AggregatedListPage(null, null);
1806     }
1807 
1808     @Override
createPage( PageContext< AggregatedListSubnetworksRequest, SubnetworkAggregatedList, Map.Entry<String, SubnetworksScopedList>> context, SubnetworkAggregatedList response)1809     protected AggregatedListPage createPage(
1810         PageContext<
1811                 AggregatedListSubnetworksRequest,
1812                 SubnetworkAggregatedList,
1813                 Map.Entry<String, SubnetworksScopedList>>
1814             context,
1815         SubnetworkAggregatedList response) {
1816       return new AggregatedListPage(context, response);
1817     }
1818 
1819     @Override
createPageAsync( PageContext< AggregatedListSubnetworksRequest, SubnetworkAggregatedList, Map.Entry<String, SubnetworksScopedList>> context, ApiFuture<SubnetworkAggregatedList> futureResponse)1820     public ApiFuture<AggregatedListPage> createPageAsync(
1821         PageContext<
1822                 AggregatedListSubnetworksRequest,
1823                 SubnetworkAggregatedList,
1824                 Map.Entry<String, SubnetworksScopedList>>
1825             context,
1826         ApiFuture<SubnetworkAggregatedList> futureResponse) {
1827       return super.createPageAsync(context, futureResponse);
1828     }
1829   }
1830 
1831   public static class AggregatedListFixedSizeCollection
1832       extends AbstractFixedSizeCollection<
1833           AggregatedListSubnetworksRequest,
1834           SubnetworkAggregatedList,
1835           Map.Entry<String, SubnetworksScopedList>,
1836           AggregatedListPage,
1837           AggregatedListFixedSizeCollection> {
1838 
AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize)1839     private AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize) {
1840       super(pages, collectionSize);
1841     }
1842 
createEmptyCollection()1843     private static AggregatedListFixedSizeCollection createEmptyCollection() {
1844       return new AggregatedListFixedSizeCollection(null, 0);
1845     }
1846 
1847     @Override
createCollection( List<AggregatedListPage> pages, int collectionSize)1848     protected AggregatedListFixedSizeCollection createCollection(
1849         List<AggregatedListPage> pages, int collectionSize) {
1850       return new AggregatedListFixedSizeCollection(pages, collectionSize);
1851     }
1852   }
1853 
1854   public static class ListPagedResponse
1855       extends AbstractPagedListResponse<
1856           ListSubnetworksRequest, SubnetworkList, Subnetwork, ListPage, ListFixedSizeCollection> {
1857 
createAsync( PageContext<ListSubnetworksRequest, SubnetworkList, Subnetwork> context, ApiFuture<SubnetworkList> futureResponse)1858     public static ApiFuture<ListPagedResponse> createAsync(
1859         PageContext<ListSubnetworksRequest, SubnetworkList, Subnetwork> context,
1860         ApiFuture<SubnetworkList> futureResponse) {
1861       ApiFuture<ListPage> futurePage =
1862           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
1863       return ApiFutures.transform(
1864           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
1865     }
1866 
ListPagedResponse(ListPage page)1867     private ListPagedResponse(ListPage page) {
1868       super(page, ListFixedSizeCollection.createEmptyCollection());
1869     }
1870   }
1871 
1872   public static class ListPage
1873       extends AbstractPage<ListSubnetworksRequest, SubnetworkList, Subnetwork, ListPage> {
1874 
ListPage( PageContext<ListSubnetworksRequest, SubnetworkList, Subnetwork> context, SubnetworkList response)1875     private ListPage(
1876         PageContext<ListSubnetworksRequest, SubnetworkList, Subnetwork> context,
1877         SubnetworkList response) {
1878       super(context, response);
1879     }
1880 
createEmptyPage()1881     private static ListPage createEmptyPage() {
1882       return new ListPage(null, null);
1883     }
1884 
1885     @Override
createPage( PageContext<ListSubnetworksRequest, SubnetworkList, Subnetwork> context, SubnetworkList response)1886     protected ListPage createPage(
1887         PageContext<ListSubnetworksRequest, SubnetworkList, Subnetwork> context,
1888         SubnetworkList response) {
1889       return new ListPage(context, response);
1890     }
1891 
1892     @Override
createPageAsync( PageContext<ListSubnetworksRequest, SubnetworkList, Subnetwork> context, ApiFuture<SubnetworkList> futureResponse)1893     public ApiFuture<ListPage> createPageAsync(
1894         PageContext<ListSubnetworksRequest, SubnetworkList, Subnetwork> context,
1895         ApiFuture<SubnetworkList> futureResponse) {
1896       return super.createPageAsync(context, futureResponse);
1897     }
1898   }
1899 
1900   public static class ListFixedSizeCollection
1901       extends AbstractFixedSizeCollection<
1902           ListSubnetworksRequest, SubnetworkList, Subnetwork, ListPage, ListFixedSizeCollection> {
1903 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1904     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
1905       super(pages, collectionSize);
1906     }
1907 
createEmptyCollection()1908     private static ListFixedSizeCollection createEmptyCollection() {
1909       return new ListFixedSizeCollection(null, 0);
1910     }
1911 
1912     @Override
createCollection(List<ListPage> pages, int collectionSize)1913     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
1914       return new ListFixedSizeCollection(pages, collectionSize);
1915     }
1916   }
1917 
1918   public static class ListUsablePagedResponse
1919       extends AbstractPagedListResponse<
1920           ListUsableSubnetworksRequest,
1921           UsableSubnetworksAggregatedList,
1922           UsableSubnetwork,
1923           ListUsablePage,
1924           ListUsableFixedSizeCollection> {
1925 
createAsync( PageContext<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList, UsableSubnetwork> context, ApiFuture<UsableSubnetworksAggregatedList> futureResponse)1926     public static ApiFuture<ListUsablePagedResponse> createAsync(
1927         PageContext<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList, UsableSubnetwork>
1928             context,
1929         ApiFuture<UsableSubnetworksAggregatedList> futureResponse) {
1930       ApiFuture<ListUsablePage> futurePage =
1931           ListUsablePage.createEmptyPage().createPageAsync(context, futureResponse);
1932       return ApiFutures.transform(
1933           futurePage, input -> new ListUsablePagedResponse(input), MoreExecutors.directExecutor());
1934     }
1935 
ListUsablePagedResponse(ListUsablePage page)1936     private ListUsablePagedResponse(ListUsablePage page) {
1937       super(page, ListUsableFixedSizeCollection.createEmptyCollection());
1938     }
1939   }
1940 
1941   public static class ListUsablePage
1942       extends AbstractPage<
1943           ListUsableSubnetworksRequest,
1944           UsableSubnetworksAggregatedList,
1945           UsableSubnetwork,
1946           ListUsablePage> {
1947 
ListUsablePage( PageContext<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList, UsableSubnetwork> context, UsableSubnetworksAggregatedList response)1948     private ListUsablePage(
1949         PageContext<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList, UsableSubnetwork>
1950             context,
1951         UsableSubnetworksAggregatedList response) {
1952       super(context, response);
1953     }
1954 
createEmptyPage()1955     private static ListUsablePage createEmptyPage() {
1956       return new ListUsablePage(null, null);
1957     }
1958 
1959     @Override
createPage( PageContext<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList, UsableSubnetwork> context, UsableSubnetworksAggregatedList response)1960     protected ListUsablePage createPage(
1961         PageContext<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList, UsableSubnetwork>
1962             context,
1963         UsableSubnetworksAggregatedList response) {
1964       return new ListUsablePage(context, response);
1965     }
1966 
1967     @Override
createPageAsync( PageContext<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList, UsableSubnetwork> context, ApiFuture<UsableSubnetworksAggregatedList> futureResponse)1968     public ApiFuture<ListUsablePage> createPageAsync(
1969         PageContext<ListUsableSubnetworksRequest, UsableSubnetworksAggregatedList, UsableSubnetwork>
1970             context,
1971         ApiFuture<UsableSubnetworksAggregatedList> futureResponse) {
1972       return super.createPageAsync(context, futureResponse);
1973     }
1974   }
1975 
1976   public static class ListUsableFixedSizeCollection
1977       extends AbstractFixedSizeCollection<
1978           ListUsableSubnetworksRequest,
1979           UsableSubnetworksAggregatedList,
1980           UsableSubnetwork,
1981           ListUsablePage,
1982           ListUsableFixedSizeCollection> {
1983 
ListUsableFixedSizeCollection(List<ListUsablePage> pages, int collectionSize)1984     private ListUsableFixedSizeCollection(List<ListUsablePage> pages, int collectionSize) {
1985       super(pages, collectionSize);
1986     }
1987 
createEmptyCollection()1988     private static ListUsableFixedSizeCollection createEmptyCollection() {
1989       return new ListUsableFixedSizeCollection(null, 0);
1990     }
1991 
1992     @Override
createCollection( List<ListUsablePage> pages, int collectionSize)1993     protected ListUsableFixedSizeCollection createCollection(
1994         List<ListUsablePage> pages, int collectionSize) {
1995       return new ListUsableFixedSizeCollection(pages, collectionSize);
1996     }
1997   }
1998 }
1999