• 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.AddressesStub;
31 import com.google.cloud.compute.v1.stub.AddressesStubSettings;
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 Addresses 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 (AddressesClient addressesClient = AddressesClient.create()) {
53  *   String project = "project-309310695";
54  *   String region = "region-934795532";
55  *   String address = "address-1147692044";
56  *   Address response = addressesClient.get(project, region, address);
57  * }
58  * }</pre>
59  *
60  * <p>Note: close() needs to be called on the AddressesClient 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 AddressesSettings to create().
84  * 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  * AddressesSettings addressesSettings =
95  *     AddressesSettings.newBuilder()
96  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
97  *         .build();
98  * AddressesClient addressesClient = AddressesClient.create(addressesSettings);
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  * AddressesSettings addressesSettings =
110  *     AddressesSettings.newBuilder().setEndpoint(myEndpoint).build();
111  * AddressesClient addressesClient = AddressesClient.create(addressesSettings);
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 AddressesClient implements BackgroundResource {
118   private final AddressesSettings settings;
119   private final AddressesStub stub;
120 
121   /** Constructs an instance of AddressesClient with default settings. */
create()122   public static final AddressesClient create() throws IOException {
123     return create(AddressesSettings.newBuilder().build());
124   }
125 
126   /**
127    * Constructs an instance of AddressesClient, 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(AddressesSettings settings)130   public static final AddressesClient create(AddressesSettings settings) throws IOException {
131     return new AddressesClient(settings);
132   }
133 
134   /**
135    * Constructs an instance of AddressesClient, using the given stub for making calls. This is for
136    * advanced usage - prefer using create(AddressesSettings).
137    */
create(AddressesStub stub)138   public static final AddressesClient create(AddressesStub stub) {
139     return new AddressesClient(stub);
140   }
141 
142   /**
143    * Constructs an instance of AddressesClient, using the given settings. This is protected so that
144    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
145    */
AddressesClient(AddressesSettings settings)146   protected AddressesClient(AddressesSettings settings) throws IOException {
147     this.settings = settings;
148     this.stub = ((AddressesStubSettings) settings.getStubSettings()).createStub();
149   }
150 
AddressesClient(AddressesStub stub)151   protected AddressesClient(AddressesStub stub) {
152     this.settings = null;
153     this.stub = stub;
154   }
155 
getSettings()156   public final AddressesSettings getSettings() {
157     return settings;
158   }
159 
getStub()160   public AddressesStub getStub() {
161     return stub;
162   }
163 
164   // AUTO-GENERATED DOCUMENTATION AND METHOD.
165   /**
166    * Retrieves an aggregated list of addresses.
167    *
168    * <p>Sample code:
169    *
170    * <pre>{@code
171    * // This snippet has been automatically generated and should be regarded as a code template only.
172    * // It will require modifications to work:
173    * // - It may require correct/in-range values for request initialization.
174    * // - It may require specifying regional endpoints when creating the service client as shown in
175    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
176    * try (AddressesClient addressesClient = AddressesClient.create()) {
177    *   String project = "project-309310695";
178    *   for (Map.Entry<String, AddressesScopedList> element :
179    *       addressesClient.aggregatedList(project).iterateAll()) {
180    *     // doThingsWith(element);
181    *   }
182    * }
183    * }</pre>
184    *
185    * @param project Project ID for this request.
186    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
187    */
aggregatedList(String project)188   public final AggregatedListPagedResponse aggregatedList(String project) {
189     AggregatedListAddressesRequest request =
190         AggregatedListAddressesRequest.newBuilder().setProject(project).build();
191     return aggregatedList(request);
192   }
193 
194   // AUTO-GENERATED DOCUMENTATION AND METHOD.
195   /**
196    * Retrieves an aggregated list of addresses.
197    *
198    * <p>Sample code:
199    *
200    * <pre>{@code
201    * // This snippet has been automatically generated and should be regarded as a code template only.
202    * // It will require modifications to work:
203    * // - It may require correct/in-range values for request initialization.
204    * // - It may require specifying regional endpoints when creating the service client as shown in
205    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
206    * try (AddressesClient addressesClient = AddressesClient.create()) {
207    *   AggregatedListAddressesRequest request =
208    *       AggregatedListAddressesRequest.newBuilder()
209    *           .setFilter("filter-1274492040")
210    *           .setIncludeAllScopes(true)
211    *           .setMaxResults(1128457243)
212    *           .setOrderBy("orderBy-1207110587")
213    *           .setPageToken("pageToken873572522")
214    *           .setProject("project-309310695")
215    *           .setReturnPartialSuccess(true)
216    *           .build();
217    *   for (Map.Entry<String, AddressesScopedList> element :
218    *       addressesClient.aggregatedList(request).iterateAll()) {
219    *     // doThingsWith(element);
220    *   }
221    * }
222    * }</pre>
223    *
224    * @param request The request object containing all of the parameters for the API call.
225    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
226    */
aggregatedList(AggregatedListAddressesRequest request)227   public final AggregatedListPagedResponse aggregatedList(AggregatedListAddressesRequest request) {
228     return aggregatedListPagedCallable().call(request);
229   }
230 
231   // AUTO-GENERATED DOCUMENTATION AND METHOD.
232   /**
233    * Retrieves an aggregated list of addresses.
234    *
235    * <p>Sample code:
236    *
237    * <pre>{@code
238    * // This snippet has been automatically generated and should be regarded as a code template only.
239    * // It will require modifications to work:
240    * // - It may require correct/in-range values for request initialization.
241    * // - It may require specifying regional endpoints when creating the service client as shown in
242    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
243    * try (AddressesClient addressesClient = AddressesClient.create()) {
244    *   AggregatedListAddressesRequest request =
245    *       AggregatedListAddressesRequest.newBuilder()
246    *           .setFilter("filter-1274492040")
247    *           .setIncludeAllScopes(true)
248    *           .setMaxResults(1128457243)
249    *           .setOrderBy("orderBy-1207110587")
250    *           .setPageToken("pageToken873572522")
251    *           .setProject("project-309310695")
252    *           .setReturnPartialSuccess(true)
253    *           .build();
254    *   ApiFuture<Map.Entry<String, AddressesScopedList>> future =
255    *       addressesClient.aggregatedListPagedCallable().futureCall(request);
256    *   // Do something.
257    *   for (Map.Entry<String, AddressesScopedList> element : future.get().iterateAll()) {
258    *     // doThingsWith(element);
259    *   }
260    * }
261    * }</pre>
262    */
263   public final UnaryCallable<AggregatedListAddressesRequest, AggregatedListPagedResponse>
aggregatedListPagedCallable()264       aggregatedListPagedCallable() {
265     return stub.aggregatedListPagedCallable();
266   }
267 
268   // AUTO-GENERATED DOCUMENTATION AND METHOD.
269   /**
270    * Retrieves an aggregated list of addresses.
271    *
272    * <p>Sample code:
273    *
274    * <pre>{@code
275    * // This snippet has been automatically generated and should be regarded as a code template only.
276    * // It will require modifications to work:
277    * // - It may require correct/in-range values for request initialization.
278    * // - It may require specifying regional endpoints when creating the service client as shown in
279    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
280    * try (AddressesClient addressesClient = AddressesClient.create()) {
281    *   AggregatedListAddressesRequest request =
282    *       AggregatedListAddressesRequest.newBuilder()
283    *           .setFilter("filter-1274492040")
284    *           .setIncludeAllScopes(true)
285    *           .setMaxResults(1128457243)
286    *           .setOrderBy("orderBy-1207110587")
287    *           .setPageToken("pageToken873572522")
288    *           .setProject("project-309310695")
289    *           .setReturnPartialSuccess(true)
290    *           .build();
291    *   while (true) {
292    *     AddressAggregatedList response = addressesClient.aggregatedListCallable().call(request);
293    *     for (Map.Entry<String, AddressesScopedList> element : response.getItemsList()) {
294    *       // doThingsWith(element);
295    *     }
296    *     String nextPageToken = response.getNextPageToken();
297    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
298    *       request = request.toBuilder().setPageToken(nextPageToken).build();
299    *     } else {
300    *       break;
301    *     }
302    *   }
303    * }
304    * }</pre>
305    */
306   public final UnaryCallable<AggregatedListAddressesRequest, AddressAggregatedList>
aggregatedListCallable()307       aggregatedListCallable() {
308     return stub.aggregatedListCallable();
309   }
310 
311   // AUTO-GENERATED DOCUMENTATION AND METHOD.
312   /**
313    * Deletes the specified address resource.
314    *
315    * <p>Sample code:
316    *
317    * <pre>{@code
318    * // This snippet has been automatically generated and should be regarded as a code template only.
319    * // It will require modifications to work:
320    * // - It may require correct/in-range values for request initialization.
321    * // - It may require specifying regional endpoints when creating the service client as shown in
322    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
323    * try (AddressesClient addressesClient = AddressesClient.create()) {
324    *   String project = "project-309310695";
325    *   String region = "region-934795532";
326    *   String address = "address-1147692044";
327    *   Operation response = addressesClient.deleteAsync(project, region, address).get();
328    * }
329    * }</pre>
330    *
331    * @param project Project ID for this request.
332    * @param region Name of the region for this request.
333    * @param address Name of the address resource to delete.
334    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
335    */
deleteAsync( String project, String region, String address)336   public final OperationFuture<Operation, Operation> deleteAsync(
337       String project, String region, String address) {
338     DeleteAddressRequest request =
339         DeleteAddressRequest.newBuilder()
340             .setProject(project)
341             .setRegion(region)
342             .setAddress(address)
343             .build();
344     return deleteAsync(request);
345   }
346 
347   // AUTO-GENERATED DOCUMENTATION AND METHOD.
348   /**
349    * Deletes the specified address resource.
350    *
351    * <p>Sample code:
352    *
353    * <pre>{@code
354    * // This snippet has been automatically generated and should be regarded as a code template only.
355    * // It will require modifications to work:
356    * // - It may require correct/in-range values for request initialization.
357    * // - It may require specifying regional endpoints when creating the service client as shown in
358    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
359    * try (AddressesClient addressesClient = AddressesClient.create()) {
360    *   DeleteAddressRequest request =
361    *       DeleteAddressRequest.newBuilder()
362    *           .setAddress("address-1147692044")
363    *           .setProject("project-309310695")
364    *           .setRegion("region-934795532")
365    *           .setRequestId("requestId693933066")
366    *           .build();
367    *   Operation response = addressesClient.deleteAsync(request).get();
368    * }
369    * }</pre>
370    *
371    * @param request The request object containing all of the parameters for the API call.
372    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
373    */
374   @BetaApi(
375       "The surface for long-running operations is not stable yet and may change in the future.")
deleteAsync(DeleteAddressRequest request)376   public final OperationFuture<Operation, Operation> deleteAsync(DeleteAddressRequest request) {
377     return deleteOperationCallable().futureCall(request);
378   }
379 
380   // AUTO-GENERATED DOCUMENTATION AND METHOD.
381   /**
382    * Deletes the specified address resource.
383    *
384    * <p>Sample code:
385    *
386    * <pre>{@code
387    * // This snippet has been automatically generated and should be regarded as a code template only.
388    * // It will require modifications to work:
389    * // - It may require correct/in-range values for request initialization.
390    * // - It may require specifying regional endpoints when creating the service client as shown in
391    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
392    * try (AddressesClient addressesClient = AddressesClient.create()) {
393    *   DeleteAddressRequest request =
394    *       DeleteAddressRequest.newBuilder()
395    *           .setAddress("address-1147692044")
396    *           .setProject("project-309310695")
397    *           .setRegion("region-934795532")
398    *           .setRequestId("requestId693933066")
399    *           .build();
400    *   OperationFuture<Operation, Operation> future =
401    *       addressesClient.deleteOperationCallable().futureCall(request);
402    *   // Do something.
403    *   Operation response = future.get();
404    * }
405    * }</pre>
406    */
407   public final OperationCallable<DeleteAddressRequest, Operation, Operation>
deleteOperationCallable()408       deleteOperationCallable() {
409     return stub.deleteOperationCallable();
410   }
411 
412   // AUTO-GENERATED DOCUMENTATION AND METHOD.
413   /**
414    * Deletes the specified address resource.
415    *
416    * <p>Sample code:
417    *
418    * <pre>{@code
419    * // This snippet has been automatically generated and should be regarded as a code template only.
420    * // It will require modifications to work:
421    * // - It may require correct/in-range values for request initialization.
422    * // - It may require specifying regional endpoints when creating the service client as shown in
423    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
424    * try (AddressesClient addressesClient = AddressesClient.create()) {
425    *   DeleteAddressRequest request =
426    *       DeleteAddressRequest.newBuilder()
427    *           .setAddress("address-1147692044")
428    *           .setProject("project-309310695")
429    *           .setRegion("region-934795532")
430    *           .setRequestId("requestId693933066")
431    *           .build();
432    *   ApiFuture<Operation> future = addressesClient.deleteCallable().futureCall(request);
433    *   // Do something.
434    *   Operation response = future.get();
435    * }
436    * }</pre>
437    */
deleteCallable()438   public final UnaryCallable<DeleteAddressRequest, Operation> deleteCallable() {
439     return stub.deleteCallable();
440   }
441 
442   // AUTO-GENERATED DOCUMENTATION AND METHOD.
443   /**
444    * Returns the specified address resource.
445    *
446    * <p>Sample code:
447    *
448    * <pre>{@code
449    * // This snippet has been automatically generated and should be regarded as a code template only.
450    * // It will require modifications to work:
451    * // - It may require correct/in-range values for request initialization.
452    * // - It may require specifying regional endpoints when creating the service client as shown in
453    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
454    * try (AddressesClient addressesClient = AddressesClient.create()) {
455    *   String project = "project-309310695";
456    *   String region = "region-934795532";
457    *   String address = "address-1147692044";
458    *   Address response = addressesClient.get(project, region, address);
459    * }
460    * }</pre>
461    *
462    * @param project Project ID for this request.
463    * @param region Name of the region for this request.
464    * @param address Name of the address resource to return.
465    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
466    */
get(String project, String region, String address)467   public final Address get(String project, String region, String address) {
468     GetAddressRequest request =
469         GetAddressRequest.newBuilder()
470             .setProject(project)
471             .setRegion(region)
472             .setAddress(address)
473             .build();
474     return get(request);
475   }
476 
477   // AUTO-GENERATED DOCUMENTATION AND METHOD.
478   /**
479    * Returns the specified address resource.
480    *
481    * <p>Sample code:
482    *
483    * <pre>{@code
484    * // This snippet has been automatically generated and should be regarded as a code template only.
485    * // It will require modifications to work:
486    * // - It may require correct/in-range values for request initialization.
487    * // - It may require specifying regional endpoints when creating the service client as shown in
488    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
489    * try (AddressesClient addressesClient = AddressesClient.create()) {
490    *   GetAddressRequest request =
491    *       GetAddressRequest.newBuilder()
492    *           .setAddress("address-1147692044")
493    *           .setProject("project-309310695")
494    *           .setRegion("region-934795532")
495    *           .build();
496    *   Address response = addressesClient.get(request);
497    * }
498    * }</pre>
499    *
500    * @param request The request object containing all of the parameters for the API call.
501    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
502    */
get(GetAddressRequest request)503   public final Address get(GetAddressRequest request) {
504     return getCallable().call(request);
505   }
506 
507   // AUTO-GENERATED DOCUMENTATION AND METHOD.
508   /**
509    * Returns the specified address resource.
510    *
511    * <p>Sample code:
512    *
513    * <pre>{@code
514    * // This snippet has been automatically generated and should be regarded as a code template only.
515    * // It will require modifications to work:
516    * // - It may require correct/in-range values for request initialization.
517    * // - It may require specifying regional endpoints when creating the service client as shown in
518    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
519    * try (AddressesClient addressesClient = AddressesClient.create()) {
520    *   GetAddressRequest request =
521    *       GetAddressRequest.newBuilder()
522    *           .setAddress("address-1147692044")
523    *           .setProject("project-309310695")
524    *           .setRegion("region-934795532")
525    *           .build();
526    *   ApiFuture<Address> future = addressesClient.getCallable().futureCall(request);
527    *   // Do something.
528    *   Address response = future.get();
529    * }
530    * }</pre>
531    */
getCallable()532   public final UnaryCallable<GetAddressRequest, Address> getCallable() {
533     return stub.getCallable();
534   }
535 
536   // AUTO-GENERATED DOCUMENTATION AND METHOD.
537   /**
538    * Creates an address resource in the specified project by using the data included in the request.
539    *
540    * <p>Sample code:
541    *
542    * <pre>{@code
543    * // This snippet has been automatically generated and should be regarded as a code template only.
544    * // It will require modifications to work:
545    * // - It may require correct/in-range values for request initialization.
546    * // - It may require specifying regional endpoints when creating the service client as shown in
547    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
548    * try (AddressesClient addressesClient = AddressesClient.create()) {
549    *   String project = "project-309310695";
550    *   String region = "region-934795532";
551    *   Address addressResource = Address.newBuilder().build();
552    *   Operation response = addressesClient.insertAsync(project, region, addressResource).get();
553    * }
554    * }</pre>
555    *
556    * @param project Project ID for this request.
557    * @param region Name of the region for this request.
558    * @param addressResource The body resource for this request
559    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
560    */
insertAsync( String project, String region, Address addressResource)561   public final OperationFuture<Operation, Operation> insertAsync(
562       String project, String region, Address addressResource) {
563     InsertAddressRequest request =
564         InsertAddressRequest.newBuilder()
565             .setProject(project)
566             .setRegion(region)
567             .setAddressResource(addressResource)
568             .build();
569     return insertAsync(request);
570   }
571 
572   // AUTO-GENERATED DOCUMENTATION AND METHOD.
573   /**
574    * Creates an address resource in the specified project by using the data included in the request.
575    *
576    * <p>Sample code:
577    *
578    * <pre>{@code
579    * // This snippet has been automatically generated and should be regarded as a code template only.
580    * // It will require modifications to work:
581    * // - It may require correct/in-range values for request initialization.
582    * // - It may require specifying regional endpoints when creating the service client as shown in
583    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
584    * try (AddressesClient addressesClient = AddressesClient.create()) {
585    *   InsertAddressRequest request =
586    *       InsertAddressRequest.newBuilder()
587    *           .setAddressResource(Address.newBuilder().build())
588    *           .setProject("project-309310695")
589    *           .setRegion("region-934795532")
590    *           .setRequestId("requestId693933066")
591    *           .build();
592    *   Operation response = addressesClient.insertAsync(request).get();
593    * }
594    * }</pre>
595    *
596    * @param request The request object containing all of the parameters for the API call.
597    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
598    */
599   @BetaApi(
600       "The surface for long-running operations is not stable yet and may change in the future.")
insertAsync(InsertAddressRequest request)601   public final OperationFuture<Operation, Operation> insertAsync(InsertAddressRequest request) {
602     return insertOperationCallable().futureCall(request);
603   }
604 
605   // AUTO-GENERATED DOCUMENTATION AND METHOD.
606   /**
607    * Creates an address resource in the specified project by using the data included in the request.
608    *
609    * <p>Sample code:
610    *
611    * <pre>{@code
612    * // This snippet has been automatically generated and should be regarded as a code template only.
613    * // It will require modifications to work:
614    * // - It may require correct/in-range values for request initialization.
615    * // - It may require specifying regional endpoints when creating the service client as shown in
616    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
617    * try (AddressesClient addressesClient = AddressesClient.create()) {
618    *   InsertAddressRequest request =
619    *       InsertAddressRequest.newBuilder()
620    *           .setAddressResource(Address.newBuilder().build())
621    *           .setProject("project-309310695")
622    *           .setRegion("region-934795532")
623    *           .setRequestId("requestId693933066")
624    *           .build();
625    *   OperationFuture<Operation, Operation> future =
626    *       addressesClient.insertOperationCallable().futureCall(request);
627    *   // Do something.
628    *   Operation response = future.get();
629    * }
630    * }</pre>
631    */
632   public final OperationCallable<InsertAddressRequest, Operation, Operation>
insertOperationCallable()633       insertOperationCallable() {
634     return stub.insertOperationCallable();
635   }
636 
637   // AUTO-GENERATED DOCUMENTATION AND METHOD.
638   /**
639    * Creates an address resource in the specified project by using the data included in the request.
640    *
641    * <p>Sample code:
642    *
643    * <pre>{@code
644    * // This snippet has been automatically generated and should be regarded as a code template only.
645    * // It will require modifications to work:
646    * // - It may require correct/in-range values for request initialization.
647    * // - It may require specifying regional endpoints when creating the service client as shown in
648    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
649    * try (AddressesClient addressesClient = AddressesClient.create()) {
650    *   InsertAddressRequest request =
651    *       InsertAddressRequest.newBuilder()
652    *           .setAddressResource(Address.newBuilder().build())
653    *           .setProject("project-309310695")
654    *           .setRegion("region-934795532")
655    *           .setRequestId("requestId693933066")
656    *           .build();
657    *   ApiFuture<Operation> future = addressesClient.insertCallable().futureCall(request);
658    *   // Do something.
659    *   Operation response = future.get();
660    * }
661    * }</pre>
662    */
insertCallable()663   public final UnaryCallable<InsertAddressRequest, Operation> insertCallable() {
664     return stub.insertCallable();
665   }
666 
667   // AUTO-GENERATED DOCUMENTATION AND METHOD.
668   /**
669    * Retrieves a list of addresses contained within the specified region.
670    *
671    * <p>Sample code:
672    *
673    * <pre>{@code
674    * // This snippet has been automatically generated and should be regarded as a code template only.
675    * // It will require modifications to work:
676    * // - It may require correct/in-range values for request initialization.
677    * // - It may require specifying regional endpoints when creating the service client as shown in
678    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
679    * try (AddressesClient addressesClient = AddressesClient.create()) {
680    *   String project = "project-309310695";
681    *   String region = "region-934795532";
682    *   for (Address element : addressesClient.list(project, region).iterateAll()) {
683    *     // doThingsWith(element);
684    *   }
685    * }
686    * }</pre>
687    *
688    * @param project Project ID for this request.
689    * @param region Name of the region for this request.
690    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
691    */
list(String project, String region)692   public final ListPagedResponse list(String project, String region) {
693     ListAddressesRequest request =
694         ListAddressesRequest.newBuilder().setProject(project).setRegion(region).build();
695     return list(request);
696   }
697 
698   // AUTO-GENERATED DOCUMENTATION AND METHOD.
699   /**
700    * Retrieves a list of addresses contained within the specified region.
701    *
702    * <p>Sample code:
703    *
704    * <pre>{@code
705    * // This snippet has been automatically generated and should be regarded as a code template only.
706    * // It will require modifications to work:
707    * // - It may require correct/in-range values for request initialization.
708    * // - It may require specifying regional endpoints when creating the service client as shown in
709    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
710    * try (AddressesClient addressesClient = AddressesClient.create()) {
711    *   ListAddressesRequest request =
712    *       ListAddressesRequest.newBuilder()
713    *           .setFilter("filter-1274492040")
714    *           .setMaxResults(1128457243)
715    *           .setOrderBy("orderBy-1207110587")
716    *           .setPageToken("pageToken873572522")
717    *           .setProject("project-309310695")
718    *           .setRegion("region-934795532")
719    *           .setReturnPartialSuccess(true)
720    *           .build();
721    *   for (Address element : addressesClient.list(request).iterateAll()) {
722    *     // doThingsWith(element);
723    *   }
724    * }
725    * }</pre>
726    *
727    * @param request The request object containing all of the parameters for the API call.
728    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
729    */
list(ListAddressesRequest request)730   public final ListPagedResponse list(ListAddressesRequest request) {
731     return listPagedCallable().call(request);
732   }
733 
734   // AUTO-GENERATED DOCUMENTATION AND METHOD.
735   /**
736    * Retrieves a list of addresses contained within the specified region.
737    *
738    * <p>Sample code:
739    *
740    * <pre>{@code
741    * // This snippet has been automatically generated and should be regarded as a code template only.
742    * // It will require modifications to work:
743    * // - It may require correct/in-range values for request initialization.
744    * // - It may require specifying regional endpoints when creating the service client as shown in
745    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
746    * try (AddressesClient addressesClient = AddressesClient.create()) {
747    *   ListAddressesRequest request =
748    *       ListAddressesRequest.newBuilder()
749    *           .setFilter("filter-1274492040")
750    *           .setMaxResults(1128457243)
751    *           .setOrderBy("orderBy-1207110587")
752    *           .setPageToken("pageToken873572522")
753    *           .setProject("project-309310695")
754    *           .setRegion("region-934795532")
755    *           .setReturnPartialSuccess(true)
756    *           .build();
757    *   ApiFuture<Address> future = addressesClient.listPagedCallable().futureCall(request);
758    *   // Do something.
759    *   for (Address element : future.get().iterateAll()) {
760    *     // doThingsWith(element);
761    *   }
762    * }
763    * }</pre>
764    */
listPagedCallable()765   public final UnaryCallable<ListAddressesRequest, ListPagedResponse> listPagedCallable() {
766     return stub.listPagedCallable();
767   }
768 
769   // AUTO-GENERATED DOCUMENTATION AND METHOD.
770   /**
771    * Retrieves a list of addresses contained within the specified region.
772    *
773    * <p>Sample code:
774    *
775    * <pre>{@code
776    * // This snippet has been automatically generated and should be regarded as a code template only.
777    * // It will require modifications to work:
778    * // - It may require correct/in-range values for request initialization.
779    * // - It may require specifying regional endpoints when creating the service client as shown in
780    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
781    * try (AddressesClient addressesClient = AddressesClient.create()) {
782    *   ListAddressesRequest request =
783    *       ListAddressesRequest.newBuilder()
784    *           .setFilter("filter-1274492040")
785    *           .setMaxResults(1128457243)
786    *           .setOrderBy("orderBy-1207110587")
787    *           .setPageToken("pageToken873572522")
788    *           .setProject("project-309310695")
789    *           .setRegion("region-934795532")
790    *           .setReturnPartialSuccess(true)
791    *           .build();
792    *   while (true) {
793    *     AddressList response = addressesClient.listCallable().call(request);
794    *     for (Address element : response.getItemsList()) {
795    *       // doThingsWith(element);
796    *     }
797    *     String nextPageToken = response.getNextPageToken();
798    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
799    *       request = request.toBuilder().setPageToken(nextPageToken).build();
800    *     } else {
801    *       break;
802    *     }
803    *   }
804    * }
805    * }</pre>
806    */
listCallable()807   public final UnaryCallable<ListAddressesRequest, AddressList> listCallable() {
808     return stub.listCallable();
809   }
810 
811   // AUTO-GENERATED DOCUMENTATION AND METHOD.
812   /**
813    * Sets the labels on an Address. To learn more about labels, read the Labeling Resources
814    * documentation.
815    *
816    * <p>Sample code:
817    *
818    * <pre>{@code
819    * // This snippet has been automatically generated and should be regarded as a code template only.
820    * // It will require modifications to work:
821    * // - It may require correct/in-range values for request initialization.
822    * // - It may require specifying regional endpoints when creating the service client as shown in
823    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
824    * try (AddressesClient addressesClient = AddressesClient.create()) {
825    *   String project = "project-309310695";
826    *   String region = "region-934795532";
827    *   String resource = "resource-341064690";
828    *   RegionSetLabelsRequest regionSetLabelsRequestResource =
829    *       RegionSetLabelsRequest.newBuilder().build();
830    *   Operation response =
831    *       addressesClient
832    *           .setLabelsAsync(project, region, resource, regionSetLabelsRequestResource)
833    *           .get();
834    * }
835    * }</pre>
836    *
837    * @param project Project ID for this request.
838    * @param region The region for this request.
839    * @param resource Name or id of the resource for this request.
840    * @param regionSetLabelsRequestResource The body resource for this request
841    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
842    */
setLabelsAsync( String project, String region, String resource, RegionSetLabelsRequest regionSetLabelsRequestResource)843   public final OperationFuture<Operation, Operation> setLabelsAsync(
844       String project,
845       String region,
846       String resource,
847       RegionSetLabelsRequest regionSetLabelsRequestResource) {
848     SetLabelsAddressRequest request =
849         SetLabelsAddressRequest.newBuilder()
850             .setProject(project)
851             .setRegion(region)
852             .setResource(resource)
853             .setRegionSetLabelsRequestResource(regionSetLabelsRequestResource)
854             .build();
855     return setLabelsAsync(request);
856   }
857 
858   // AUTO-GENERATED DOCUMENTATION AND METHOD.
859   /**
860    * Sets the labels on an Address. To learn more about labels, read the Labeling Resources
861    * documentation.
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 (AddressesClient addressesClient = AddressesClient.create()) {
872    *   SetLabelsAddressRequest request =
873    *       SetLabelsAddressRequest.newBuilder()
874    *           .setProject("project-309310695")
875    *           .setRegion("region-934795532")
876    *           .setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build())
877    *           .setRequestId("requestId693933066")
878    *           .setResource("resource-341064690")
879    *           .build();
880    *   Operation response = addressesClient.setLabelsAsync(request).get();
881    * }
882    * }</pre>
883    *
884    * @param request The request object containing all of the parameters for the API call.
885    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
886    */
887   @BetaApi(
888       "The surface for long-running operations is not stable yet and may change in the future.")
setLabelsAsync( SetLabelsAddressRequest request)889   public final OperationFuture<Operation, Operation> setLabelsAsync(
890       SetLabelsAddressRequest request) {
891     return setLabelsOperationCallable().futureCall(request);
892   }
893 
894   // AUTO-GENERATED DOCUMENTATION AND METHOD.
895   /**
896    * Sets the labels on an Address. To learn more about labels, read the Labeling Resources
897    * documentation.
898    *
899    * <p>Sample code:
900    *
901    * <pre>{@code
902    * // This snippet has been automatically generated and should be regarded as a code template only.
903    * // It will require modifications to work:
904    * // - It may require correct/in-range values for request initialization.
905    * // - It may require specifying regional endpoints when creating the service client as shown in
906    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
907    * try (AddressesClient addressesClient = AddressesClient.create()) {
908    *   SetLabelsAddressRequest request =
909    *       SetLabelsAddressRequest.newBuilder()
910    *           .setProject("project-309310695")
911    *           .setRegion("region-934795532")
912    *           .setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build())
913    *           .setRequestId("requestId693933066")
914    *           .setResource("resource-341064690")
915    *           .build();
916    *   OperationFuture<Operation, Operation> future =
917    *       addressesClient.setLabelsOperationCallable().futureCall(request);
918    *   // Do something.
919    *   Operation response = future.get();
920    * }
921    * }</pre>
922    */
923   public final OperationCallable<SetLabelsAddressRequest, Operation, Operation>
setLabelsOperationCallable()924       setLabelsOperationCallable() {
925     return stub.setLabelsOperationCallable();
926   }
927 
928   // AUTO-GENERATED DOCUMENTATION AND METHOD.
929   /**
930    * Sets the labels on an Address. To learn more about labels, read the Labeling Resources
931    * documentation.
932    *
933    * <p>Sample code:
934    *
935    * <pre>{@code
936    * // This snippet has been automatically generated and should be regarded as a code template only.
937    * // It will require modifications to work:
938    * // - It may require correct/in-range values for request initialization.
939    * // - It may require specifying regional endpoints when creating the service client as shown in
940    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
941    * try (AddressesClient addressesClient = AddressesClient.create()) {
942    *   SetLabelsAddressRequest request =
943    *       SetLabelsAddressRequest.newBuilder()
944    *           .setProject("project-309310695")
945    *           .setRegion("region-934795532")
946    *           .setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build())
947    *           .setRequestId("requestId693933066")
948    *           .setResource("resource-341064690")
949    *           .build();
950    *   ApiFuture<Operation> future = addressesClient.setLabelsCallable().futureCall(request);
951    *   // Do something.
952    *   Operation response = future.get();
953    * }
954    * }</pre>
955    */
setLabelsCallable()956   public final UnaryCallable<SetLabelsAddressRequest, Operation> setLabelsCallable() {
957     return stub.setLabelsCallable();
958   }
959 
960   @Override
close()961   public final void close() {
962     stub.close();
963   }
964 
965   @Override
shutdown()966   public void shutdown() {
967     stub.shutdown();
968   }
969 
970   @Override
isShutdown()971   public boolean isShutdown() {
972     return stub.isShutdown();
973   }
974 
975   @Override
isTerminated()976   public boolean isTerminated() {
977     return stub.isTerminated();
978   }
979 
980   @Override
shutdownNow()981   public void shutdownNow() {
982     stub.shutdownNow();
983   }
984 
985   @Override
awaitTermination(long duration, TimeUnit unit)986   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
987     return stub.awaitTermination(duration, unit);
988   }
989 
990   public static class AggregatedListPagedResponse
991       extends AbstractPagedListResponse<
992           AggregatedListAddressesRequest,
993           AddressAggregatedList,
994           Map.Entry<String, AddressesScopedList>,
995           AggregatedListPage,
996           AggregatedListFixedSizeCollection> {
997 
createAsync( PageContext< AggregatedListAddressesRequest, AddressAggregatedList, Map.Entry<String, AddressesScopedList>> context, ApiFuture<AddressAggregatedList> futureResponse)998     public static ApiFuture<AggregatedListPagedResponse> createAsync(
999         PageContext<
1000                 AggregatedListAddressesRequest,
1001                 AddressAggregatedList,
1002                 Map.Entry<String, AddressesScopedList>>
1003             context,
1004         ApiFuture<AddressAggregatedList> futureResponse) {
1005       ApiFuture<AggregatedListPage> futurePage =
1006           AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse);
1007       return ApiFutures.transform(
1008           futurePage,
1009           input -> new AggregatedListPagedResponse(input),
1010           MoreExecutors.directExecutor());
1011     }
1012 
AggregatedListPagedResponse(AggregatedListPage page)1013     private AggregatedListPagedResponse(AggregatedListPage page) {
1014       super(page, AggregatedListFixedSizeCollection.createEmptyCollection());
1015     }
1016   }
1017 
1018   public static class AggregatedListPage
1019       extends AbstractPage<
1020           AggregatedListAddressesRequest,
1021           AddressAggregatedList,
1022           Map.Entry<String, AddressesScopedList>,
1023           AggregatedListPage> {
1024 
AggregatedListPage( PageContext< AggregatedListAddressesRequest, AddressAggregatedList, Map.Entry<String, AddressesScopedList>> context, AddressAggregatedList response)1025     private AggregatedListPage(
1026         PageContext<
1027                 AggregatedListAddressesRequest,
1028                 AddressAggregatedList,
1029                 Map.Entry<String, AddressesScopedList>>
1030             context,
1031         AddressAggregatedList response) {
1032       super(context, response);
1033     }
1034 
createEmptyPage()1035     private static AggregatedListPage createEmptyPage() {
1036       return new AggregatedListPage(null, null);
1037     }
1038 
1039     @Override
createPage( PageContext< AggregatedListAddressesRequest, AddressAggregatedList, Map.Entry<String, AddressesScopedList>> context, AddressAggregatedList response)1040     protected AggregatedListPage createPage(
1041         PageContext<
1042                 AggregatedListAddressesRequest,
1043                 AddressAggregatedList,
1044                 Map.Entry<String, AddressesScopedList>>
1045             context,
1046         AddressAggregatedList response) {
1047       return new AggregatedListPage(context, response);
1048     }
1049 
1050     @Override
createPageAsync( PageContext< AggregatedListAddressesRequest, AddressAggregatedList, Map.Entry<String, AddressesScopedList>> context, ApiFuture<AddressAggregatedList> futureResponse)1051     public ApiFuture<AggregatedListPage> createPageAsync(
1052         PageContext<
1053                 AggregatedListAddressesRequest,
1054                 AddressAggregatedList,
1055                 Map.Entry<String, AddressesScopedList>>
1056             context,
1057         ApiFuture<AddressAggregatedList> futureResponse) {
1058       return super.createPageAsync(context, futureResponse);
1059     }
1060   }
1061 
1062   public static class AggregatedListFixedSizeCollection
1063       extends AbstractFixedSizeCollection<
1064           AggregatedListAddressesRequest,
1065           AddressAggregatedList,
1066           Map.Entry<String, AddressesScopedList>,
1067           AggregatedListPage,
1068           AggregatedListFixedSizeCollection> {
1069 
AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize)1070     private AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize) {
1071       super(pages, collectionSize);
1072     }
1073 
createEmptyCollection()1074     private static AggregatedListFixedSizeCollection createEmptyCollection() {
1075       return new AggregatedListFixedSizeCollection(null, 0);
1076     }
1077 
1078     @Override
createCollection( List<AggregatedListPage> pages, int collectionSize)1079     protected AggregatedListFixedSizeCollection createCollection(
1080         List<AggregatedListPage> pages, int collectionSize) {
1081       return new AggregatedListFixedSizeCollection(pages, collectionSize);
1082     }
1083   }
1084 
1085   public static class ListPagedResponse
1086       extends AbstractPagedListResponse<
1087           ListAddressesRequest, AddressList, Address, ListPage, ListFixedSizeCollection> {
1088 
createAsync( PageContext<ListAddressesRequest, AddressList, Address> context, ApiFuture<AddressList> futureResponse)1089     public static ApiFuture<ListPagedResponse> createAsync(
1090         PageContext<ListAddressesRequest, AddressList, Address> context,
1091         ApiFuture<AddressList> futureResponse) {
1092       ApiFuture<ListPage> futurePage =
1093           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
1094       return ApiFutures.transform(
1095           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
1096     }
1097 
ListPagedResponse(ListPage page)1098     private ListPagedResponse(ListPage page) {
1099       super(page, ListFixedSizeCollection.createEmptyCollection());
1100     }
1101   }
1102 
1103   public static class ListPage
1104       extends AbstractPage<ListAddressesRequest, AddressList, Address, ListPage> {
1105 
ListPage( PageContext<ListAddressesRequest, AddressList, Address> context, AddressList response)1106     private ListPage(
1107         PageContext<ListAddressesRequest, AddressList, Address> context, AddressList response) {
1108       super(context, response);
1109     }
1110 
createEmptyPage()1111     private static ListPage createEmptyPage() {
1112       return new ListPage(null, null);
1113     }
1114 
1115     @Override
createPage( PageContext<ListAddressesRequest, AddressList, Address> context, AddressList response)1116     protected ListPage createPage(
1117         PageContext<ListAddressesRequest, AddressList, Address> context, AddressList response) {
1118       return new ListPage(context, response);
1119     }
1120 
1121     @Override
createPageAsync( PageContext<ListAddressesRequest, AddressList, Address> context, ApiFuture<AddressList> futureResponse)1122     public ApiFuture<ListPage> createPageAsync(
1123         PageContext<ListAddressesRequest, AddressList, Address> context,
1124         ApiFuture<AddressList> futureResponse) {
1125       return super.createPageAsync(context, futureResponse);
1126     }
1127   }
1128 
1129   public static class ListFixedSizeCollection
1130       extends AbstractFixedSizeCollection<
1131           ListAddressesRequest, AddressList, Address, ListPage, ListFixedSizeCollection> {
1132 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1133     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
1134       super(pages, collectionSize);
1135     }
1136 
createEmptyCollection()1137     private static ListFixedSizeCollection createEmptyCollection() {
1138       return new ListFixedSizeCollection(null, 0);
1139     }
1140 
1141     @Override
createCollection(List<ListPage> pages, int collectionSize)1142     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
1143       return new ListFixedSizeCollection(pages, collectionSize);
1144     }
1145   }
1146 }
1147