• 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.AutoscalersStub;
31 import com.google.cloud.compute.v1.stub.AutoscalersStubSettings;
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 Autoscalers 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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
53  *   String project = "project-309310695";
54  *   String zone = "zone3744684";
55  *   String autoscaler = "autoscaler517258967";
56  *   Autoscaler response = autoscalersClient.get(project, zone, autoscaler);
57  * }
58  * }</pre>
59  *
60  * <p>Note: close() needs to be called on the AutoscalersClient 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 AutoscalersSettings 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  * AutoscalersSettings autoscalersSettings =
95  *     AutoscalersSettings.newBuilder()
96  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
97  *         .build();
98  * AutoscalersClient autoscalersClient = AutoscalersClient.create(autoscalersSettings);
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  * AutoscalersSettings autoscalersSettings =
110  *     AutoscalersSettings.newBuilder().setEndpoint(myEndpoint).build();
111  * AutoscalersClient autoscalersClient = AutoscalersClient.create(autoscalersSettings);
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 AutoscalersClient implements BackgroundResource {
118   private final AutoscalersSettings settings;
119   private final AutoscalersStub stub;
120 
121   /** Constructs an instance of AutoscalersClient with default settings. */
create()122   public static final AutoscalersClient create() throws IOException {
123     return create(AutoscalersSettings.newBuilder().build());
124   }
125 
126   /**
127    * Constructs an instance of AutoscalersClient, 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(AutoscalersSettings settings)130   public static final AutoscalersClient create(AutoscalersSettings settings) throws IOException {
131     return new AutoscalersClient(settings);
132   }
133 
134   /**
135    * Constructs an instance of AutoscalersClient, using the given stub for making calls. This is for
136    * advanced usage - prefer using create(AutoscalersSettings).
137    */
create(AutoscalersStub stub)138   public static final AutoscalersClient create(AutoscalersStub stub) {
139     return new AutoscalersClient(stub);
140   }
141 
142   /**
143    * Constructs an instance of AutoscalersClient, 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    */
AutoscalersClient(AutoscalersSettings settings)147   protected AutoscalersClient(AutoscalersSettings settings) throws IOException {
148     this.settings = settings;
149     this.stub = ((AutoscalersStubSettings) settings.getStubSettings()).createStub();
150   }
151 
AutoscalersClient(AutoscalersStub stub)152   protected AutoscalersClient(AutoscalersStub stub) {
153     this.settings = null;
154     this.stub = stub;
155   }
156 
getSettings()157   public final AutoscalersSettings getSettings() {
158     return settings;
159   }
160 
getStub()161   public AutoscalersStub getStub() {
162     return stub;
163   }
164 
165   // AUTO-GENERATED DOCUMENTATION AND METHOD.
166   /**
167    * Retrieves an aggregated list of autoscalers.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
178    *   String project = "project-309310695";
179    *   for (Map.Entry<String, AutoscalersScopedList> element :
180    *       autoscalersClient.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     AggregatedListAutoscalersRequest request =
191         AggregatedListAutoscalersRequest.newBuilder().setProject(project).build();
192     return aggregatedList(request);
193   }
194 
195   // AUTO-GENERATED DOCUMENTATION AND METHOD.
196   /**
197    * Retrieves an aggregated list of autoscalers.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
208    *   AggregatedListAutoscalersRequest request =
209    *       AggregatedListAutoscalersRequest.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, AutoscalersScopedList> element :
219    *       autoscalersClient.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( AggregatedListAutoscalersRequest request)228   public final AggregatedListPagedResponse aggregatedList(
229       AggregatedListAutoscalersRequest request) {
230     return aggregatedListPagedCallable().call(request);
231   }
232 
233   // AUTO-GENERATED DOCUMENTATION AND METHOD.
234   /**
235    * Retrieves an aggregated list of autoscalers.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
246    *   AggregatedListAutoscalersRequest request =
247    *       AggregatedListAutoscalersRequest.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, AutoscalersScopedList>> future =
257    *       autoscalersClient.aggregatedListPagedCallable().futureCall(request);
258    *   // Do something.
259    *   for (Map.Entry<String, AutoscalersScopedList> element : future.get().iterateAll()) {
260    *     // doThingsWith(element);
261    *   }
262    * }
263    * }</pre>
264    */
265   public final UnaryCallable<AggregatedListAutoscalersRequest, AggregatedListPagedResponse>
aggregatedListPagedCallable()266       aggregatedListPagedCallable() {
267     return stub.aggregatedListPagedCallable();
268   }
269 
270   // AUTO-GENERATED DOCUMENTATION AND METHOD.
271   /**
272    * Retrieves an aggregated list of autoscalers.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
283    *   AggregatedListAutoscalersRequest request =
284    *       AggregatedListAutoscalersRequest.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    *     AutoscalerAggregatedList response =
295    *         autoscalersClient.aggregatedListCallable().call(request);
296    *     for (Map.Entry<String, AutoscalersScopedList> 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<AggregatedListAutoscalersRequest, AutoscalerAggregatedList>
aggregatedListCallable()310       aggregatedListCallable() {
311     return stub.aggregatedListCallable();
312   }
313 
314   // AUTO-GENERATED DOCUMENTATION AND METHOD.
315   /**
316    * Deletes the specified autoscaler.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
327    *   String project = "project-309310695";
328    *   String zone = "zone3744684";
329    *   String autoscaler = "autoscaler517258967";
330    *   Operation response = autoscalersClient.deleteAsync(project, zone, autoscaler).get();
331    * }
332    * }</pre>
333    *
334    * @param project Project ID for this request.
335    * @param zone Name of the zone for this request.
336    * @param autoscaler Name of the autoscaler to delete.
337    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
338    */
deleteAsync( String project, String zone, String autoscaler)339   public final OperationFuture<Operation, Operation> deleteAsync(
340       String project, String zone, String autoscaler) {
341     DeleteAutoscalerRequest request =
342         DeleteAutoscalerRequest.newBuilder()
343             .setProject(project)
344             .setZone(zone)
345             .setAutoscaler(autoscaler)
346             .build();
347     return deleteAsync(request);
348   }
349 
350   // AUTO-GENERATED DOCUMENTATION AND METHOD.
351   /**
352    * Deletes the specified autoscaler.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
363    *   DeleteAutoscalerRequest request =
364    *       DeleteAutoscalerRequest.newBuilder()
365    *           .setAutoscaler("autoscaler517258967")
366    *           .setProject("project-309310695")
367    *           .setRequestId("requestId693933066")
368    *           .setZone("zone3744684")
369    *           .build();
370    *   Operation response = autoscalersClient.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(DeleteAutoscalerRequest request)379   public final OperationFuture<Operation, Operation> deleteAsync(DeleteAutoscalerRequest request) {
380     return deleteOperationCallable().futureCall(request);
381   }
382 
383   // AUTO-GENERATED DOCUMENTATION AND METHOD.
384   /**
385    * Deletes the specified autoscaler.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
396    *   DeleteAutoscalerRequest request =
397    *       DeleteAutoscalerRequest.newBuilder()
398    *           .setAutoscaler("autoscaler517258967")
399    *           .setProject("project-309310695")
400    *           .setRequestId("requestId693933066")
401    *           .setZone("zone3744684")
402    *           .build();
403    *   OperationFuture<Operation, Operation> future =
404    *       autoscalersClient.deleteOperationCallable().futureCall(request);
405    *   // Do something.
406    *   Operation response = future.get();
407    * }
408    * }</pre>
409    */
410   public final OperationCallable<DeleteAutoscalerRequest, Operation, Operation>
deleteOperationCallable()411       deleteOperationCallable() {
412     return stub.deleteOperationCallable();
413   }
414 
415   // AUTO-GENERATED DOCUMENTATION AND METHOD.
416   /**
417    * Deletes the specified autoscaler.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
428    *   DeleteAutoscalerRequest request =
429    *       DeleteAutoscalerRequest.newBuilder()
430    *           .setAutoscaler("autoscaler517258967")
431    *           .setProject("project-309310695")
432    *           .setRequestId("requestId693933066")
433    *           .setZone("zone3744684")
434    *           .build();
435    *   ApiFuture<Operation> future = autoscalersClient.deleteCallable().futureCall(request);
436    *   // Do something.
437    *   Operation response = future.get();
438    * }
439    * }</pre>
440    */
deleteCallable()441   public final UnaryCallable<DeleteAutoscalerRequest, Operation> deleteCallable() {
442     return stub.deleteCallable();
443   }
444 
445   // AUTO-GENERATED DOCUMENTATION AND METHOD.
446   /**
447    * Returns the specified autoscaler resource.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
458    *   String project = "project-309310695";
459    *   String zone = "zone3744684";
460    *   String autoscaler = "autoscaler517258967";
461    *   Autoscaler response = autoscalersClient.get(project, zone, autoscaler);
462    * }
463    * }</pre>
464    *
465    * @param project Project ID for this request.
466    * @param zone Name of the zone for this request.
467    * @param autoscaler Name of the autoscaler to return.
468    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
469    */
get(String project, String zone, String autoscaler)470   public final Autoscaler get(String project, String zone, String autoscaler) {
471     GetAutoscalerRequest request =
472         GetAutoscalerRequest.newBuilder()
473             .setProject(project)
474             .setZone(zone)
475             .setAutoscaler(autoscaler)
476             .build();
477     return get(request);
478   }
479 
480   // AUTO-GENERATED DOCUMENTATION AND METHOD.
481   /**
482    * Returns the specified autoscaler resource.
483    *
484    * <p>Sample code:
485    *
486    * <pre>{@code
487    * // This snippet has been automatically generated and should be regarded as a code template only.
488    * // It will require modifications to work:
489    * // - It may require correct/in-range values for request initialization.
490    * // - It may require specifying regional endpoints when creating the service client as shown in
491    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
492    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
493    *   GetAutoscalerRequest request =
494    *       GetAutoscalerRequest.newBuilder()
495    *           .setAutoscaler("autoscaler517258967")
496    *           .setProject("project-309310695")
497    *           .setZone("zone3744684")
498    *           .build();
499    *   Autoscaler response = autoscalersClient.get(request);
500    * }
501    * }</pre>
502    *
503    * @param request The request object containing all of the parameters for the API call.
504    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
505    */
get(GetAutoscalerRequest request)506   public final Autoscaler get(GetAutoscalerRequest request) {
507     return getCallable().call(request);
508   }
509 
510   // AUTO-GENERATED DOCUMENTATION AND METHOD.
511   /**
512    * Returns the specified autoscaler resource.
513    *
514    * <p>Sample code:
515    *
516    * <pre>{@code
517    * // This snippet has been automatically generated and should be regarded as a code template only.
518    * // It will require modifications to work:
519    * // - It may require correct/in-range values for request initialization.
520    * // - It may require specifying regional endpoints when creating the service client as shown in
521    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
522    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
523    *   GetAutoscalerRequest request =
524    *       GetAutoscalerRequest.newBuilder()
525    *           .setAutoscaler("autoscaler517258967")
526    *           .setProject("project-309310695")
527    *           .setZone("zone3744684")
528    *           .build();
529    *   ApiFuture<Autoscaler> future = autoscalersClient.getCallable().futureCall(request);
530    *   // Do something.
531    *   Autoscaler response = future.get();
532    * }
533    * }</pre>
534    */
getCallable()535   public final UnaryCallable<GetAutoscalerRequest, Autoscaler> getCallable() {
536     return stub.getCallable();
537   }
538 
539   // AUTO-GENERATED DOCUMENTATION AND METHOD.
540   /**
541    * Creates an autoscaler in the specified project using the data included in the request.
542    *
543    * <p>Sample code:
544    *
545    * <pre>{@code
546    * // This snippet has been automatically generated and should be regarded as a code template only.
547    * // It will require modifications to work:
548    * // - It may require correct/in-range values for request initialization.
549    * // - It may require specifying regional endpoints when creating the service client as shown in
550    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
551    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
552    *   String project = "project-309310695";
553    *   String zone = "zone3744684";
554    *   Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
555    *   Operation response = autoscalersClient.insertAsync(project, zone, autoscalerResource).get();
556    * }
557    * }</pre>
558    *
559    * @param project Project ID for this request.
560    * @param zone Name of the zone for this request.
561    * @param autoscalerResource The body resource for this request
562    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
563    */
insertAsync( String project, String zone, Autoscaler autoscalerResource)564   public final OperationFuture<Operation, Operation> insertAsync(
565       String project, String zone, Autoscaler autoscalerResource) {
566     InsertAutoscalerRequest request =
567         InsertAutoscalerRequest.newBuilder()
568             .setProject(project)
569             .setZone(zone)
570             .setAutoscalerResource(autoscalerResource)
571             .build();
572     return insertAsync(request);
573   }
574 
575   // AUTO-GENERATED DOCUMENTATION AND METHOD.
576   /**
577    * Creates an autoscaler in the specified project using the data included in the request.
578    *
579    * <p>Sample code:
580    *
581    * <pre>{@code
582    * // This snippet has been automatically generated and should be regarded as a code template only.
583    * // It will require modifications to work:
584    * // - It may require correct/in-range values for request initialization.
585    * // - It may require specifying regional endpoints when creating the service client as shown in
586    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
587    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
588    *   InsertAutoscalerRequest request =
589    *       InsertAutoscalerRequest.newBuilder()
590    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
591    *           .setProject("project-309310695")
592    *           .setRequestId("requestId693933066")
593    *           .setZone("zone3744684")
594    *           .build();
595    *   Operation response = autoscalersClient.insertAsync(request).get();
596    * }
597    * }</pre>
598    *
599    * @param request The request object containing all of the parameters for the API call.
600    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
601    */
602   @BetaApi(
603       "The surface for long-running operations is not stable yet and may change in the future.")
insertAsync(InsertAutoscalerRequest request)604   public final OperationFuture<Operation, Operation> insertAsync(InsertAutoscalerRequest request) {
605     return insertOperationCallable().futureCall(request);
606   }
607 
608   // AUTO-GENERATED DOCUMENTATION AND METHOD.
609   /**
610    * Creates an autoscaler in the specified project using the data included in the request.
611    *
612    * <p>Sample code:
613    *
614    * <pre>{@code
615    * // This snippet has been automatically generated and should be regarded as a code template only.
616    * // It will require modifications to work:
617    * // - It may require correct/in-range values for request initialization.
618    * // - It may require specifying regional endpoints when creating the service client as shown in
619    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
620    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
621    *   InsertAutoscalerRequest request =
622    *       InsertAutoscalerRequest.newBuilder()
623    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
624    *           .setProject("project-309310695")
625    *           .setRequestId("requestId693933066")
626    *           .setZone("zone3744684")
627    *           .build();
628    *   OperationFuture<Operation, Operation> future =
629    *       autoscalersClient.insertOperationCallable().futureCall(request);
630    *   // Do something.
631    *   Operation response = future.get();
632    * }
633    * }</pre>
634    */
635   public final OperationCallable<InsertAutoscalerRequest, Operation, Operation>
insertOperationCallable()636       insertOperationCallable() {
637     return stub.insertOperationCallable();
638   }
639 
640   // AUTO-GENERATED DOCUMENTATION AND METHOD.
641   /**
642    * Creates an autoscaler in the specified project using the data included in the request.
643    *
644    * <p>Sample code:
645    *
646    * <pre>{@code
647    * // This snippet has been automatically generated and should be regarded as a code template only.
648    * // It will require modifications to work:
649    * // - It may require correct/in-range values for request initialization.
650    * // - It may require specifying regional endpoints when creating the service client as shown in
651    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
652    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
653    *   InsertAutoscalerRequest request =
654    *       InsertAutoscalerRequest.newBuilder()
655    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
656    *           .setProject("project-309310695")
657    *           .setRequestId("requestId693933066")
658    *           .setZone("zone3744684")
659    *           .build();
660    *   ApiFuture<Operation> future = autoscalersClient.insertCallable().futureCall(request);
661    *   // Do something.
662    *   Operation response = future.get();
663    * }
664    * }</pre>
665    */
insertCallable()666   public final UnaryCallable<InsertAutoscalerRequest, Operation> insertCallable() {
667     return stub.insertCallable();
668   }
669 
670   // AUTO-GENERATED DOCUMENTATION AND METHOD.
671   /**
672    * Retrieves a list of autoscalers contained within the specified zone.
673    *
674    * <p>Sample code:
675    *
676    * <pre>{@code
677    * // This snippet has been automatically generated and should be regarded as a code template only.
678    * // It will require modifications to work:
679    * // - It may require correct/in-range values for request initialization.
680    * // - It may require specifying regional endpoints when creating the service client as shown in
681    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
682    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
683    *   String project = "project-309310695";
684    *   String zone = "zone3744684";
685    *   for (Autoscaler element : autoscalersClient.list(project, zone).iterateAll()) {
686    *     // doThingsWith(element);
687    *   }
688    * }
689    * }</pre>
690    *
691    * @param project Project ID for this request.
692    * @param zone Name of the zone for this request.
693    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
694    */
list(String project, String zone)695   public final ListPagedResponse list(String project, String zone) {
696     ListAutoscalersRequest request =
697         ListAutoscalersRequest.newBuilder().setProject(project).setZone(zone).build();
698     return list(request);
699   }
700 
701   // AUTO-GENERATED DOCUMENTATION AND METHOD.
702   /**
703    * Retrieves a list of autoscalers contained within the specified zone.
704    *
705    * <p>Sample code:
706    *
707    * <pre>{@code
708    * // This snippet has been automatically generated and should be regarded as a code template only.
709    * // It will require modifications to work:
710    * // - It may require correct/in-range values for request initialization.
711    * // - It may require specifying regional endpoints when creating the service client as shown in
712    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
713    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
714    *   ListAutoscalersRequest request =
715    *       ListAutoscalersRequest.newBuilder()
716    *           .setFilter("filter-1274492040")
717    *           .setMaxResults(1128457243)
718    *           .setOrderBy("orderBy-1207110587")
719    *           .setPageToken("pageToken873572522")
720    *           .setProject("project-309310695")
721    *           .setReturnPartialSuccess(true)
722    *           .setZone("zone3744684")
723    *           .build();
724    *   for (Autoscaler element : autoscalersClient.list(request).iterateAll()) {
725    *     // doThingsWith(element);
726    *   }
727    * }
728    * }</pre>
729    *
730    * @param request The request object containing all of the parameters for the API call.
731    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
732    */
list(ListAutoscalersRequest request)733   public final ListPagedResponse list(ListAutoscalersRequest request) {
734     return listPagedCallable().call(request);
735   }
736 
737   // AUTO-GENERATED DOCUMENTATION AND METHOD.
738   /**
739    * Retrieves a list of autoscalers contained within the specified zone.
740    *
741    * <p>Sample code:
742    *
743    * <pre>{@code
744    * // This snippet has been automatically generated and should be regarded as a code template only.
745    * // It will require modifications to work:
746    * // - It may require correct/in-range values for request initialization.
747    * // - It may require specifying regional endpoints when creating the service client as shown in
748    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
749    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
750    *   ListAutoscalersRequest request =
751    *       ListAutoscalersRequest.newBuilder()
752    *           .setFilter("filter-1274492040")
753    *           .setMaxResults(1128457243)
754    *           .setOrderBy("orderBy-1207110587")
755    *           .setPageToken("pageToken873572522")
756    *           .setProject("project-309310695")
757    *           .setReturnPartialSuccess(true)
758    *           .setZone("zone3744684")
759    *           .build();
760    *   ApiFuture<Autoscaler> future = autoscalersClient.listPagedCallable().futureCall(request);
761    *   // Do something.
762    *   for (Autoscaler element : future.get().iterateAll()) {
763    *     // doThingsWith(element);
764    *   }
765    * }
766    * }</pre>
767    */
listPagedCallable()768   public final UnaryCallable<ListAutoscalersRequest, ListPagedResponse> listPagedCallable() {
769     return stub.listPagedCallable();
770   }
771 
772   // AUTO-GENERATED DOCUMENTATION AND METHOD.
773   /**
774    * Retrieves a list of autoscalers contained within the specified zone.
775    *
776    * <p>Sample code:
777    *
778    * <pre>{@code
779    * // This snippet has been automatically generated and should be regarded as a code template only.
780    * // It will require modifications to work:
781    * // - It may require correct/in-range values for request initialization.
782    * // - It may require specifying regional endpoints when creating the service client as shown in
783    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
784    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
785    *   ListAutoscalersRequest request =
786    *       ListAutoscalersRequest.newBuilder()
787    *           .setFilter("filter-1274492040")
788    *           .setMaxResults(1128457243)
789    *           .setOrderBy("orderBy-1207110587")
790    *           .setPageToken("pageToken873572522")
791    *           .setProject("project-309310695")
792    *           .setReturnPartialSuccess(true)
793    *           .setZone("zone3744684")
794    *           .build();
795    *   while (true) {
796    *     AutoscalerList response = autoscalersClient.listCallable().call(request);
797    *     for (Autoscaler element : response.getItemsList()) {
798    *       // doThingsWith(element);
799    *     }
800    *     String nextPageToken = response.getNextPageToken();
801    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
802    *       request = request.toBuilder().setPageToken(nextPageToken).build();
803    *     } else {
804    *       break;
805    *     }
806    *   }
807    * }
808    * }</pre>
809    */
listCallable()810   public final UnaryCallable<ListAutoscalersRequest, AutoscalerList> listCallable() {
811     return stub.listCallable();
812   }
813 
814   // AUTO-GENERATED DOCUMENTATION AND METHOD.
815   /**
816    * Updates an autoscaler in the specified project using the data included in the request. This
817    * method supports PATCH semantics and uses the JSON merge patch format and processing rules.
818    *
819    * <p>Sample code:
820    *
821    * <pre>{@code
822    * // This snippet has been automatically generated and should be regarded as a code template only.
823    * // It will require modifications to work:
824    * // - It may require correct/in-range values for request initialization.
825    * // - It may require specifying regional endpoints when creating the service client as shown in
826    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
827    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
828    *   String project = "project-309310695";
829    *   String zone = "zone3744684";
830    *   Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
831    *   Operation response = autoscalersClient.patchAsync(project, zone, autoscalerResource).get();
832    * }
833    * }</pre>
834    *
835    * @param project Project ID for this request.
836    * @param zone Name of the zone for this request.
837    * @param autoscalerResource The body resource for this request
838    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
839    */
patchAsync( String project, String zone, Autoscaler autoscalerResource)840   public final OperationFuture<Operation, Operation> patchAsync(
841       String project, String zone, Autoscaler autoscalerResource) {
842     PatchAutoscalerRequest request =
843         PatchAutoscalerRequest.newBuilder()
844             .setProject(project)
845             .setZone(zone)
846             .setAutoscalerResource(autoscalerResource)
847             .build();
848     return patchAsync(request);
849   }
850 
851   // AUTO-GENERATED DOCUMENTATION AND METHOD.
852   /**
853    * Updates an autoscaler in the specified project using the data included in the request. This
854    * method supports PATCH semantics and uses the JSON merge patch format and processing rules.
855    *
856    * <p>Sample code:
857    *
858    * <pre>{@code
859    * // This snippet has been automatically generated and should be regarded as a code template only.
860    * // It will require modifications to work:
861    * // - It may require correct/in-range values for request initialization.
862    * // - It may require specifying regional endpoints when creating the service client as shown in
863    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
864    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
865    *   PatchAutoscalerRequest request =
866    *       PatchAutoscalerRequest.newBuilder()
867    *           .setAutoscaler("autoscaler517258967")
868    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
869    *           .setProject("project-309310695")
870    *           .setRequestId("requestId693933066")
871    *           .setZone("zone3744684")
872    *           .build();
873    *   Operation response = autoscalersClient.patchAsync(request).get();
874    * }
875    * }</pre>
876    *
877    * @param request The request object containing all of the parameters for the API call.
878    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
879    */
880   @BetaApi(
881       "The surface for long-running operations is not stable yet and may change in the future.")
patchAsync(PatchAutoscalerRequest request)882   public final OperationFuture<Operation, Operation> patchAsync(PatchAutoscalerRequest request) {
883     return patchOperationCallable().futureCall(request);
884   }
885 
886   // AUTO-GENERATED DOCUMENTATION AND METHOD.
887   /**
888    * Updates an autoscaler in the specified project using the data included in the request. This
889    * method supports PATCH semantics and uses the JSON merge patch format and processing rules.
890    *
891    * <p>Sample code:
892    *
893    * <pre>{@code
894    * // This snippet has been automatically generated and should be regarded as a code template only.
895    * // It will require modifications to work:
896    * // - It may require correct/in-range values for request initialization.
897    * // - It may require specifying regional endpoints when creating the service client as shown in
898    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
899    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
900    *   PatchAutoscalerRequest request =
901    *       PatchAutoscalerRequest.newBuilder()
902    *           .setAutoscaler("autoscaler517258967")
903    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
904    *           .setProject("project-309310695")
905    *           .setRequestId("requestId693933066")
906    *           .setZone("zone3744684")
907    *           .build();
908    *   OperationFuture<Operation, Operation> future =
909    *       autoscalersClient.patchOperationCallable().futureCall(request);
910    *   // Do something.
911    *   Operation response = future.get();
912    * }
913    * }</pre>
914    */
915   public final OperationCallable<PatchAutoscalerRequest, Operation, Operation>
patchOperationCallable()916       patchOperationCallable() {
917     return stub.patchOperationCallable();
918   }
919 
920   // AUTO-GENERATED DOCUMENTATION AND METHOD.
921   /**
922    * Updates an autoscaler in the specified project using the data included in the request. This
923    * method supports PATCH semantics and uses the JSON merge patch format and processing rules.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
934    *   PatchAutoscalerRequest request =
935    *       PatchAutoscalerRequest.newBuilder()
936    *           .setAutoscaler("autoscaler517258967")
937    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
938    *           .setProject("project-309310695")
939    *           .setRequestId("requestId693933066")
940    *           .setZone("zone3744684")
941    *           .build();
942    *   ApiFuture<Operation> future = autoscalersClient.patchCallable().futureCall(request);
943    *   // Do something.
944    *   Operation response = future.get();
945    * }
946    * }</pre>
947    */
patchCallable()948   public final UnaryCallable<PatchAutoscalerRequest, Operation> patchCallable() {
949     return stub.patchCallable();
950   }
951 
952   // AUTO-GENERATED DOCUMENTATION AND METHOD.
953   /**
954    * Updates an autoscaler in the specified project using the data included in the request.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
965    *   String project = "project-309310695";
966    *   String zone = "zone3744684";
967    *   Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
968    *   Operation response = autoscalersClient.updateAsync(project, zone, autoscalerResource).get();
969    * }
970    * }</pre>
971    *
972    * @param project Project ID for this request.
973    * @param zone Name of the zone for this request.
974    * @param autoscalerResource The body resource for this request
975    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
976    */
updateAsync( String project, String zone, Autoscaler autoscalerResource)977   public final OperationFuture<Operation, Operation> updateAsync(
978       String project, String zone, Autoscaler autoscalerResource) {
979     UpdateAutoscalerRequest request =
980         UpdateAutoscalerRequest.newBuilder()
981             .setProject(project)
982             .setZone(zone)
983             .setAutoscalerResource(autoscalerResource)
984             .build();
985     return updateAsync(request);
986   }
987 
988   // AUTO-GENERATED DOCUMENTATION AND METHOD.
989   /**
990    * Updates an autoscaler in the specified project using the data included in the request.
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 (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
1001    *   UpdateAutoscalerRequest request =
1002    *       UpdateAutoscalerRequest.newBuilder()
1003    *           .setAutoscaler("autoscaler517258967")
1004    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
1005    *           .setProject("project-309310695")
1006    *           .setRequestId("requestId693933066")
1007    *           .setZone("zone3744684")
1008    *           .build();
1009    *   Operation response = autoscalersClient.updateAsync(request).get();
1010    * }
1011    * }</pre>
1012    *
1013    * @param request The request object containing all of the parameters for the API call.
1014    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1015    */
1016   @BetaApi(
1017       "The surface for long-running operations is not stable yet and may change in the future.")
updateAsync(UpdateAutoscalerRequest request)1018   public final OperationFuture<Operation, Operation> updateAsync(UpdateAutoscalerRequest request) {
1019     return updateOperationCallable().futureCall(request);
1020   }
1021 
1022   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1023   /**
1024    * Updates an autoscaler in the specified project using the data included in the request.
1025    *
1026    * <p>Sample code:
1027    *
1028    * <pre>{@code
1029    * // This snippet has been automatically generated and should be regarded as a code template only.
1030    * // It will require modifications to work:
1031    * // - It may require correct/in-range values for request initialization.
1032    * // - It may require specifying regional endpoints when creating the service client as shown in
1033    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1034    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
1035    *   UpdateAutoscalerRequest request =
1036    *       UpdateAutoscalerRequest.newBuilder()
1037    *           .setAutoscaler("autoscaler517258967")
1038    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
1039    *           .setProject("project-309310695")
1040    *           .setRequestId("requestId693933066")
1041    *           .setZone("zone3744684")
1042    *           .build();
1043    *   OperationFuture<Operation, Operation> future =
1044    *       autoscalersClient.updateOperationCallable().futureCall(request);
1045    *   // Do something.
1046    *   Operation response = future.get();
1047    * }
1048    * }</pre>
1049    */
1050   public final OperationCallable<UpdateAutoscalerRequest, Operation, Operation>
updateOperationCallable()1051       updateOperationCallable() {
1052     return stub.updateOperationCallable();
1053   }
1054 
1055   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1056   /**
1057    * Updates an autoscaler in the specified project using the data included in the request.
1058    *
1059    * <p>Sample code:
1060    *
1061    * <pre>{@code
1062    * // This snippet has been automatically generated and should be regarded as a code template only.
1063    * // It will require modifications to work:
1064    * // - It may require correct/in-range values for request initialization.
1065    * // - It may require specifying regional endpoints when creating the service client as shown in
1066    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1067    * try (AutoscalersClient autoscalersClient = AutoscalersClient.create()) {
1068    *   UpdateAutoscalerRequest request =
1069    *       UpdateAutoscalerRequest.newBuilder()
1070    *           .setAutoscaler("autoscaler517258967")
1071    *           .setAutoscalerResource(Autoscaler.newBuilder().build())
1072    *           .setProject("project-309310695")
1073    *           .setRequestId("requestId693933066")
1074    *           .setZone("zone3744684")
1075    *           .build();
1076    *   ApiFuture<Operation> future = autoscalersClient.updateCallable().futureCall(request);
1077    *   // Do something.
1078    *   Operation response = future.get();
1079    * }
1080    * }</pre>
1081    */
updateCallable()1082   public final UnaryCallable<UpdateAutoscalerRequest, Operation> updateCallable() {
1083     return stub.updateCallable();
1084   }
1085 
1086   @Override
close()1087   public final void close() {
1088     stub.close();
1089   }
1090 
1091   @Override
shutdown()1092   public void shutdown() {
1093     stub.shutdown();
1094   }
1095 
1096   @Override
isShutdown()1097   public boolean isShutdown() {
1098     return stub.isShutdown();
1099   }
1100 
1101   @Override
isTerminated()1102   public boolean isTerminated() {
1103     return stub.isTerminated();
1104   }
1105 
1106   @Override
shutdownNow()1107   public void shutdownNow() {
1108     stub.shutdownNow();
1109   }
1110 
1111   @Override
awaitTermination(long duration, TimeUnit unit)1112   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1113     return stub.awaitTermination(duration, unit);
1114   }
1115 
1116   public static class AggregatedListPagedResponse
1117       extends AbstractPagedListResponse<
1118           AggregatedListAutoscalersRequest,
1119           AutoscalerAggregatedList,
1120           Map.Entry<String, AutoscalersScopedList>,
1121           AggregatedListPage,
1122           AggregatedListFixedSizeCollection> {
1123 
createAsync( PageContext< AggregatedListAutoscalersRequest, AutoscalerAggregatedList, Map.Entry<String, AutoscalersScopedList>> context, ApiFuture<AutoscalerAggregatedList> futureResponse)1124     public static ApiFuture<AggregatedListPagedResponse> createAsync(
1125         PageContext<
1126                 AggregatedListAutoscalersRequest,
1127                 AutoscalerAggregatedList,
1128                 Map.Entry<String, AutoscalersScopedList>>
1129             context,
1130         ApiFuture<AutoscalerAggregatedList> futureResponse) {
1131       ApiFuture<AggregatedListPage> futurePage =
1132           AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse);
1133       return ApiFutures.transform(
1134           futurePage,
1135           input -> new AggregatedListPagedResponse(input),
1136           MoreExecutors.directExecutor());
1137     }
1138 
AggregatedListPagedResponse(AggregatedListPage page)1139     private AggregatedListPagedResponse(AggregatedListPage page) {
1140       super(page, AggregatedListFixedSizeCollection.createEmptyCollection());
1141     }
1142   }
1143 
1144   public static class AggregatedListPage
1145       extends AbstractPage<
1146           AggregatedListAutoscalersRequest,
1147           AutoscalerAggregatedList,
1148           Map.Entry<String, AutoscalersScopedList>,
1149           AggregatedListPage> {
1150 
AggregatedListPage( PageContext< AggregatedListAutoscalersRequest, AutoscalerAggregatedList, Map.Entry<String, AutoscalersScopedList>> context, AutoscalerAggregatedList response)1151     private AggregatedListPage(
1152         PageContext<
1153                 AggregatedListAutoscalersRequest,
1154                 AutoscalerAggregatedList,
1155                 Map.Entry<String, AutoscalersScopedList>>
1156             context,
1157         AutoscalerAggregatedList response) {
1158       super(context, response);
1159     }
1160 
createEmptyPage()1161     private static AggregatedListPage createEmptyPage() {
1162       return new AggregatedListPage(null, null);
1163     }
1164 
1165     @Override
createPage( PageContext< AggregatedListAutoscalersRequest, AutoscalerAggregatedList, Map.Entry<String, AutoscalersScopedList>> context, AutoscalerAggregatedList response)1166     protected AggregatedListPage createPage(
1167         PageContext<
1168                 AggregatedListAutoscalersRequest,
1169                 AutoscalerAggregatedList,
1170                 Map.Entry<String, AutoscalersScopedList>>
1171             context,
1172         AutoscalerAggregatedList response) {
1173       return new AggregatedListPage(context, response);
1174     }
1175 
1176     @Override
createPageAsync( PageContext< AggregatedListAutoscalersRequest, AutoscalerAggregatedList, Map.Entry<String, AutoscalersScopedList>> context, ApiFuture<AutoscalerAggregatedList> futureResponse)1177     public ApiFuture<AggregatedListPage> createPageAsync(
1178         PageContext<
1179                 AggregatedListAutoscalersRequest,
1180                 AutoscalerAggregatedList,
1181                 Map.Entry<String, AutoscalersScopedList>>
1182             context,
1183         ApiFuture<AutoscalerAggregatedList> futureResponse) {
1184       return super.createPageAsync(context, futureResponse);
1185     }
1186   }
1187 
1188   public static class AggregatedListFixedSizeCollection
1189       extends AbstractFixedSizeCollection<
1190           AggregatedListAutoscalersRequest,
1191           AutoscalerAggregatedList,
1192           Map.Entry<String, AutoscalersScopedList>,
1193           AggregatedListPage,
1194           AggregatedListFixedSizeCollection> {
1195 
AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize)1196     private AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize) {
1197       super(pages, collectionSize);
1198     }
1199 
createEmptyCollection()1200     private static AggregatedListFixedSizeCollection createEmptyCollection() {
1201       return new AggregatedListFixedSizeCollection(null, 0);
1202     }
1203 
1204     @Override
createCollection( List<AggregatedListPage> pages, int collectionSize)1205     protected AggregatedListFixedSizeCollection createCollection(
1206         List<AggregatedListPage> pages, int collectionSize) {
1207       return new AggregatedListFixedSizeCollection(pages, collectionSize);
1208     }
1209   }
1210 
1211   public static class ListPagedResponse
1212       extends AbstractPagedListResponse<
1213           ListAutoscalersRequest, AutoscalerList, Autoscaler, ListPage, ListFixedSizeCollection> {
1214 
createAsync( PageContext<ListAutoscalersRequest, AutoscalerList, Autoscaler> context, ApiFuture<AutoscalerList> futureResponse)1215     public static ApiFuture<ListPagedResponse> createAsync(
1216         PageContext<ListAutoscalersRequest, AutoscalerList, Autoscaler> context,
1217         ApiFuture<AutoscalerList> futureResponse) {
1218       ApiFuture<ListPage> futurePage =
1219           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
1220       return ApiFutures.transform(
1221           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
1222     }
1223 
ListPagedResponse(ListPage page)1224     private ListPagedResponse(ListPage page) {
1225       super(page, ListFixedSizeCollection.createEmptyCollection());
1226     }
1227   }
1228 
1229   public static class ListPage
1230       extends AbstractPage<ListAutoscalersRequest, AutoscalerList, Autoscaler, ListPage> {
1231 
ListPage( PageContext<ListAutoscalersRequest, AutoscalerList, Autoscaler> context, AutoscalerList response)1232     private ListPage(
1233         PageContext<ListAutoscalersRequest, AutoscalerList, Autoscaler> context,
1234         AutoscalerList response) {
1235       super(context, response);
1236     }
1237 
createEmptyPage()1238     private static ListPage createEmptyPage() {
1239       return new ListPage(null, null);
1240     }
1241 
1242     @Override
createPage( PageContext<ListAutoscalersRequest, AutoscalerList, Autoscaler> context, AutoscalerList response)1243     protected ListPage createPage(
1244         PageContext<ListAutoscalersRequest, AutoscalerList, Autoscaler> context,
1245         AutoscalerList response) {
1246       return new ListPage(context, response);
1247     }
1248 
1249     @Override
createPageAsync( PageContext<ListAutoscalersRequest, AutoscalerList, Autoscaler> context, ApiFuture<AutoscalerList> futureResponse)1250     public ApiFuture<ListPage> createPageAsync(
1251         PageContext<ListAutoscalersRequest, AutoscalerList, Autoscaler> context,
1252         ApiFuture<AutoscalerList> futureResponse) {
1253       return super.createPageAsync(context, futureResponse);
1254     }
1255   }
1256 
1257   public static class ListFixedSizeCollection
1258       extends AbstractFixedSizeCollection<
1259           ListAutoscalersRequest, AutoscalerList, Autoscaler, ListPage, ListFixedSizeCollection> {
1260 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1261     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
1262       super(pages, collectionSize);
1263     }
1264 
createEmptyCollection()1265     private static ListFixedSizeCollection createEmptyCollection() {
1266       return new ListFixedSizeCollection(null, 0);
1267     }
1268 
1269     @Override
createCollection(List<ListPage> pages, int collectionSize)1270     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
1271       return new ListFixedSizeCollection(pages, collectionSize);
1272     }
1273   }
1274 }
1275