• 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.run.v2;
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.httpjson.longrunning.OperationsClient;
24 import com.google.api.gax.longrunning.OperationFuture;
25 import com.google.api.gax.paging.AbstractFixedSizeCollection;
26 import com.google.api.gax.paging.AbstractPage;
27 import com.google.api.gax.paging.AbstractPagedListResponse;
28 import com.google.api.gax.rpc.OperationCallable;
29 import com.google.api.gax.rpc.PageContext;
30 import com.google.api.gax.rpc.UnaryCallable;
31 import com.google.cloud.run.v2.stub.ServicesStub;
32 import com.google.cloud.run.v2.stub.ServicesStubSettings;
33 import com.google.common.util.concurrent.MoreExecutors;
34 import com.google.iam.v1.GetIamPolicyRequest;
35 import com.google.iam.v1.Policy;
36 import com.google.iam.v1.SetIamPolicyRequest;
37 import com.google.iam.v1.TestIamPermissionsRequest;
38 import com.google.iam.v1.TestIamPermissionsResponse;
39 import com.google.longrunning.Operation;
40 import java.io.IOException;
41 import java.util.List;
42 import java.util.concurrent.TimeUnit;
43 import javax.annotation.Generated;
44 
45 // AUTO-GENERATED DOCUMENTATION AND CLASS.
46 /**
47  * Service Description: Cloud Run Service Control Plane API
48  *
49  * <p>This class provides the ability to make remote calls to the backing service through method
50  * calls that map to API methods. Sample code to get started:
51  *
52  * <pre>{@code
53  * // This snippet has been automatically generated and should be regarded as a code template only.
54  * // It will require modifications to work:
55  * // - It may require correct/in-range values for request initialization.
56  * // - It may require specifying regional endpoints when creating the service client as shown in
57  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
58  * try (ServicesClient servicesClient = ServicesClient.create()) {
59  *   ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]");
60  *   Service response = servicesClient.getService(name);
61  * }
62  * }</pre>
63  *
64  * <p>Note: close() needs to be called on the ServicesClient object to clean up resources such as
65  * threads. In the example above, try-with-resources is used, which automatically calls close().
66  *
67  * <p>The surface of this class includes several types of Java methods for each of the API's
68  * methods:
69  *
70  * <ol>
71  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
72  *       converted into function parameters. It may be the case that not all fields are available as
73  *       parameters, and not every API method will have a flattened method entry point.
74  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
75  *       which must be constructed before the call. Not every API method will have a request object
76  *       method.
77  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
78  *       callable object, which can be used to initiate calls to the service.
79  * </ol>
80  *
81  * <p>See the individual methods for example code.
82  *
83  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
84  * these names, this class includes a format method for each type of name, and additionally a parse
85  * method to extract the individual identifiers contained within names that are returned.
86  *
87  * <p>This class can be customized by passing in a custom instance of ServicesSettings to create().
88  * For example:
89  *
90  * <p>To customize credentials:
91  *
92  * <pre>{@code
93  * // This snippet has been automatically generated and should be regarded as a code template only.
94  * // It will require modifications to work:
95  * // - It may require correct/in-range values for request initialization.
96  * // - It may require specifying regional endpoints when creating the service client as shown in
97  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
98  * ServicesSettings servicesSettings =
99  *     ServicesSettings.newBuilder()
100  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
101  *         .build();
102  * ServicesClient servicesClient = ServicesClient.create(servicesSettings);
103  * }</pre>
104  *
105  * <p>To customize the endpoint:
106  *
107  * <pre>{@code
108  * // This snippet has been automatically generated and should be regarded as a code template only.
109  * // It will require modifications to work:
110  * // - It may require correct/in-range values for request initialization.
111  * // - It may require specifying regional endpoints when creating the service client as shown in
112  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
113  * ServicesSettings servicesSettings =
114  *     ServicesSettings.newBuilder().setEndpoint(myEndpoint).build();
115  * ServicesClient servicesClient = ServicesClient.create(servicesSettings);
116  * }</pre>
117  *
118  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
119  * the wire:
120  *
121  * <pre>{@code
122  * // This snippet has been automatically generated and should be regarded as a code template only.
123  * // It will require modifications to work:
124  * // - It may require correct/in-range values for request initialization.
125  * // - It may require specifying regional endpoints when creating the service client as shown in
126  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
127  * ServicesSettings servicesSettings = ServicesSettings.newHttpJsonBuilder().build();
128  * ServicesClient servicesClient = ServicesClient.create(servicesSettings);
129  * }</pre>
130  *
131  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
132  */
133 @Generated("by gapic-generator-java")
134 public class ServicesClient implements BackgroundResource {
135   private final ServicesSettings settings;
136   private final ServicesStub stub;
137   private final OperationsClient httpJsonOperationsClient;
138   private final com.google.longrunning.OperationsClient operationsClient;
139 
140   /** Constructs an instance of ServicesClient with default settings. */
create()141   public static final ServicesClient create() throws IOException {
142     return create(ServicesSettings.newBuilder().build());
143   }
144 
145   /**
146    * Constructs an instance of ServicesClient, using the given settings. The channels are created
147    * based on the settings passed in, or defaults for any settings that are not set.
148    */
create(ServicesSettings settings)149   public static final ServicesClient create(ServicesSettings settings) throws IOException {
150     return new ServicesClient(settings);
151   }
152 
153   /**
154    * Constructs an instance of ServicesClient, using the given stub for making calls. This is for
155    * advanced usage - prefer using create(ServicesSettings).
156    */
create(ServicesStub stub)157   public static final ServicesClient create(ServicesStub stub) {
158     return new ServicesClient(stub);
159   }
160 
161   /**
162    * Constructs an instance of ServicesClient, using the given settings. This is protected so that
163    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
164    */
ServicesClient(ServicesSettings settings)165   protected ServicesClient(ServicesSettings settings) throws IOException {
166     this.settings = settings;
167     this.stub = ((ServicesStubSettings) settings.getStubSettings()).createStub();
168     this.operationsClient =
169         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
170     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
171   }
172 
ServicesClient(ServicesStub stub)173   protected ServicesClient(ServicesStub stub) {
174     this.settings = null;
175     this.stub = stub;
176     this.operationsClient =
177         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
178     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
179   }
180 
getSettings()181   public final ServicesSettings getSettings() {
182     return settings;
183   }
184 
getStub()185   public ServicesStub getStub() {
186     return stub;
187   }
188 
189   /**
190    * Returns the OperationsClient that can be used to query the status of a long-running operation
191    * returned by another API method call.
192    */
getOperationsClient()193   public final com.google.longrunning.OperationsClient getOperationsClient() {
194     return operationsClient;
195   }
196 
197   /**
198    * Returns the OperationsClient that can be used to query the status of a long-running operation
199    * returned by another API method call.
200    */
201   @BetaApi
getHttpJsonOperationsClient()202   public final OperationsClient getHttpJsonOperationsClient() {
203     return httpJsonOperationsClient;
204   }
205 
206   // AUTO-GENERATED DOCUMENTATION AND METHOD.
207   /**
208    * Creates a new Service in a given project and location.
209    *
210    * <p>Sample code:
211    *
212    * <pre>{@code
213    * // This snippet has been automatically generated and should be regarded as a code template only.
214    * // It will require modifications to work:
215    * // - It may require correct/in-range values for request initialization.
216    * // - It may require specifying regional endpoints when creating the service client as shown in
217    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
218    * try (ServicesClient servicesClient = ServicesClient.create()) {
219    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
220    *   Service service = Service.newBuilder().build();
221    *   String serviceId = "serviceId-194185552";
222    *   Service response = servicesClient.createServiceAsync(parent, service, serviceId).get();
223    * }
224    * }</pre>
225    *
226    * @param parent Required. The location and project in which this service should be created.
227    *     Format: projects/{project}/locations/{location}, where {project} can be project id or
228    *     number. Only lowercase characters, digits, and hyphens.
229    * @param service Required. The Service instance to create.
230    * @param serviceId Required. The unique identifier for the Service. It must begin with letter,
231    *     and cannot end with hyphen; must contain fewer than 50 characters. The name of the service
232    *     becomes {parent}/services/{service_id}.
233    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
234    */
createServiceAsync( LocationName parent, Service service, String serviceId)235   public final OperationFuture<Service, Service> createServiceAsync(
236       LocationName parent, Service service, String serviceId) {
237     CreateServiceRequest request =
238         CreateServiceRequest.newBuilder()
239             .setParent(parent == null ? null : parent.toString())
240             .setService(service)
241             .setServiceId(serviceId)
242             .build();
243     return createServiceAsync(request);
244   }
245 
246   // AUTO-GENERATED DOCUMENTATION AND METHOD.
247   /**
248    * Creates a new Service in a given project and location.
249    *
250    * <p>Sample code:
251    *
252    * <pre>{@code
253    * // This snippet has been automatically generated and should be regarded as a code template only.
254    * // It will require modifications to work:
255    * // - It may require correct/in-range values for request initialization.
256    * // - It may require specifying regional endpoints when creating the service client as shown in
257    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
258    * try (ServicesClient servicesClient = ServicesClient.create()) {
259    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
260    *   Service service = Service.newBuilder().build();
261    *   String serviceId = "serviceId-194185552";
262    *   Service response = servicesClient.createServiceAsync(parent, service, serviceId).get();
263    * }
264    * }</pre>
265    *
266    * @param parent Required. The location and project in which this service should be created.
267    *     Format: projects/{project}/locations/{location}, where {project} can be project id or
268    *     number. Only lowercase characters, digits, and hyphens.
269    * @param service Required. The Service instance to create.
270    * @param serviceId Required. The unique identifier for the Service. It must begin with letter,
271    *     and cannot end with hyphen; must contain fewer than 50 characters. The name of the service
272    *     becomes {parent}/services/{service_id}.
273    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
274    */
createServiceAsync( String parent, Service service, String serviceId)275   public final OperationFuture<Service, Service> createServiceAsync(
276       String parent, Service service, String serviceId) {
277     CreateServiceRequest request =
278         CreateServiceRequest.newBuilder()
279             .setParent(parent)
280             .setService(service)
281             .setServiceId(serviceId)
282             .build();
283     return createServiceAsync(request);
284   }
285 
286   // AUTO-GENERATED DOCUMENTATION AND METHOD.
287   /**
288    * Creates a new Service in a given project and location.
289    *
290    * <p>Sample code:
291    *
292    * <pre>{@code
293    * // This snippet has been automatically generated and should be regarded as a code template only.
294    * // It will require modifications to work:
295    * // - It may require correct/in-range values for request initialization.
296    * // - It may require specifying regional endpoints when creating the service client as shown in
297    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
298    * try (ServicesClient servicesClient = ServicesClient.create()) {
299    *   CreateServiceRequest request =
300    *       CreateServiceRequest.newBuilder()
301    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
302    *           .setService(Service.newBuilder().build())
303    *           .setServiceId("serviceId-194185552")
304    *           .setValidateOnly(true)
305    *           .build();
306    *   Service response = servicesClient.createServiceAsync(request).get();
307    * }
308    * }</pre>
309    *
310    * @param request The request object containing all of the parameters for the API call.
311    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
312    */
createServiceAsync(CreateServiceRequest request)313   public final OperationFuture<Service, Service> createServiceAsync(CreateServiceRequest request) {
314     return createServiceOperationCallable().futureCall(request);
315   }
316 
317   // AUTO-GENERATED DOCUMENTATION AND METHOD.
318   /**
319    * Creates a new Service in a given project and location.
320    *
321    * <p>Sample code:
322    *
323    * <pre>{@code
324    * // This snippet has been automatically generated and should be regarded as a code template only.
325    * // It will require modifications to work:
326    * // - It may require correct/in-range values for request initialization.
327    * // - It may require specifying regional endpoints when creating the service client as shown in
328    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
329    * try (ServicesClient servicesClient = ServicesClient.create()) {
330    *   CreateServiceRequest request =
331    *       CreateServiceRequest.newBuilder()
332    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
333    *           .setService(Service.newBuilder().build())
334    *           .setServiceId("serviceId-194185552")
335    *           .setValidateOnly(true)
336    *           .build();
337    *   OperationFuture<Service, Service> future =
338    *       servicesClient.createServiceOperationCallable().futureCall(request);
339    *   // Do something.
340    *   Service response = future.get();
341    * }
342    * }</pre>
343    */
344   public final OperationCallable<CreateServiceRequest, Service, Service>
createServiceOperationCallable()345       createServiceOperationCallable() {
346     return stub.createServiceOperationCallable();
347   }
348 
349   // AUTO-GENERATED DOCUMENTATION AND METHOD.
350   /**
351    * Creates a new Service in a given project and location.
352    *
353    * <p>Sample code:
354    *
355    * <pre>{@code
356    * // This snippet has been automatically generated and should be regarded as a code template only.
357    * // It will require modifications to work:
358    * // - It may require correct/in-range values for request initialization.
359    * // - It may require specifying regional endpoints when creating the service client as shown in
360    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
361    * try (ServicesClient servicesClient = ServicesClient.create()) {
362    *   CreateServiceRequest request =
363    *       CreateServiceRequest.newBuilder()
364    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
365    *           .setService(Service.newBuilder().build())
366    *           .setServiceId("serviceId-194185552")
367    *           .setValidateOnly(true)
368    *           .build();
369    *   ApiFuture<Operation> future = servicesClient.createServiceCallable().futureCall(request);
370    *   // Do something.
371    *   Operation response = future.get();
372    * }
373    * }</pre>
374    */
createServiceCallable()375   public final UnaryCallable<CreateServiceRequest, Operation> createServiceCallable() {
376     return stub.createServiceCallable();
377   }
378 
379   // AUTO-GENERATED DOCUMENTATION AND METHOD.
380   /**
381    * Gets information about a Service.
382    *
383    * <p>Sample code:
384    *
385    * <pre>{@code
386    * // This snippet has been automatically generated and should be regarded as a code template only.
387    * // It will require modifications to work:
388    * // - It may require correct/in-range values for request initialization.
389    * // - It may require specifying regional endpoints when creating the service client as shown in
390    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
391    * try (ServicesClient servicesClient = ServicesClient.create()) {
392    *   ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]");
393    *   Service response = servicesClient.getService(name);
394    * }
395    * }</pre>
396    *
397    * @param name Required. The full name of the Service. Format:
398    *     projects/{project}/locations/{location}/services/{service}, where {project} can be project
399    *     id or number.
400    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
401    */
getService(ServiceName name)402   public final Service getService(ServiceName name) {
403     GetServiceRequest request =
404         GetServiceRequest.newBuilder().setName(name == null ? null : name.toString()).build();
405     return getService(request);
406   }
407 
408   // AUTO-GENERATED DOCUMENTATION AND METHOD.
409   /**
410    * Gets information about a Service.
411    *
412    * <p>Sample code:
413    *
414    * <pre>{@code
415    * // This snippet has been automatically generated and should be regarded as a code template only.
416    * // It will require modifications to work:
417    * // - It may require correct/in-range values for request initialization.
418    * // - It may require specifying regional endpoints when creating the service client as shown in
419    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
420    * try (ServicesClient servicesClient = ServicesClient.create()) {
421    *   String name = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString();
422    *   Service response = servicesClient.getService(name);
423    * }
424    * }</pre>
425    *
426    * @param name Required. The full name of the Service. Format:
427    *     projects/{project}/locations/{location}/services/{service}, where {project} can be project
428    *     id or number.
429    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
430    */
getService(String name)431   public final Service getService(String name) {
432     GetServiceRequest request = GetServiceRequest.newBuilder().setName(name).build();
433     return getService(request);
434   }
435 
436   // AUTO-GENERATED DOCUMENTATION AND METHOD.
437   /**
438    * Gets information about a Service.
439    *
440    * <p>Sample code:
441    *
442    * <pre>{@code
443    * // This snippet has been automatically generated and should be regarded as a code template only.
444    * // It will require modifications to work:
445    * // - It may require correct/in-range values for request initialization.
446    * // - It may require specifying regional endpoints when creating the service client as shown in
447    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
448    * try (ServicesClient servicesClient = ServicesClient.create()) {
449    *   GetServiceRequest request =
450    *       GetServiceRequest.newBuilder()
451    *           .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
452    *           .build();
453    *   Service response = servicesClient.getService(request);
454    * }
455    * }</pre>
456    *
457    * @param request The request object containing all of the parameters for the API call.
458    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
459    */
getService(GetServiceRequest request)460   public final Service getService(GetServiceRequest request) {
461     return getServiceCallable().call(request);
462   }
463 
464   // AUTO-GENERATED DOCUMENTATION AND METHOD.
465   /**
466    * Gets information about a Service.
467    *
468    * <p>Sample code:
469    *
470    * <pre>{@code
471    * // This snippet has been automatically generated and should be regarded as a code template only.
472    * // It will require modifications to work:
473    * // - It may require correct/in-range values for request initialization.
474    * // - It may require specifying regional endpoints when creating the service client as shown in
475    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
476    * try (ServicesClient servicesClient = ServicesClient.create()) {
477    *   GetServiceRequest request =
478    *       GetServiceRequest.newBuilder()
479    *           .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
480    *           .build();
481    *   ApiFuture<Service> future = servicesClient.getServiceCallable().futureCall(request);
482    *   // Do something.
483    *   Service response = future.get();
484    * }
485    * }</pre>
486    */
getServiceCallable()487   public final UnaryCallable<GetServiceRequest, Service> getServiceCallable() {
488     return stub.getServiceCallable();
489   }
490 
491   // AUTO-GENERATED DOCUMENTATION AND METHOD.
492   /**
493    * Lists Services.
494    *
495    * <p>Sample code:
496    *
497    * <pre>{@code
498    * // This snippet has been automatically generated and should be regarded as a code template only.
499    * // It will require modifications to work:
500    * // - It may require correct/in-range values for request initialization.
501    * // - It may require specifying regional endpoints when creating the service client as shown in
502    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
503    * try (ServicesClient servicesClient = ServicesClient.create()) {
504    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
505    *   for (Service element : servicesClient.listServices(parent).iterateAll()) {
506    *     // doThingsWith(element);
507    *   }
508    * }
509    * }</pre>
510    *
511    * @param parent Required. The location and project to list resources on. Location must be a valid
512    *     Google Cloud region, and cannot be the "-" wildcard. Format:
513    *     projects/{project}/locations/{location}, where {project} can be project id or number.
514    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
515    */
listServices(LocationName parent)516   public final ListServicesPagedResponse listServices(LocationName parent) {
517     ListServicesRequest request =
518         ListServicesRequest.newBuilder()
519             .setParent(parent == null ? null : parent.toString())
520             .build();
521     return listServices(request);
522   }
523 
524   // AUTO-GENERATED DOCUMENTATION AND METHOD.
525   /**
526    * Lists Services.
527    *
528    * <p>Sample code:
529    *
530    * <pre>{@code
531    * // This snippet has been automatically generated and should be regarded as a code template only.
532    * // It will require modifications to work:
533    * // - It may require correct/in-range values for request initialization.
534    * // - It may require specifying regional endpoints when creating the service client as shown in
535    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
536    * try (ServicesClient servicesClient = ServicesClient.create()) {
537    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
538    *   for (Service element : servicesClient.listServices(parent).iterateAll()) {
539    *     // doThingsWith(element);
540    *   }
541    * }
542    * }</pre>
543    *
544    * @param parent Required. The location and project to list resources on. Location must be a valid
545    *     Google Cloud region, and cannot be the "-" wildcard. Format:
546    *     projects/{project}/locations/{location}, where {project} can be project id or number.
547    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
548    */
listServices(String parent)549   public final ListServicesPagedResponse listServices(String parent) {
550     ListServicesRequest request = ListServicesRequest.newBuilder().setParent(parent).build();
551     return listServices(request);
552   }
553 
554   // AUTO-GENERATED DOCUMENTATION AND METHOD.
555   /**
556    * Lists Services.
557    *
558    * <p>Sample code:
559    *
560    * <pre>{@code
561    * // This snippet has been automatically generated and should be regarded as a code template only.
562    * // It will require modifications to work:
563    * // - It may require correct/in-range values for request initialization.
564    * // - It may require specifying regional endpoints when creating the service client as shown in
565    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
566    * try (ServicesClient servicesClient = ServicesClient.create()) {
567    *   ListServicesRequest request =
568    *       ListServicesRequest.newBuilder()
569    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
570    *           .setPageSize(883849137)
571    *           .setPageToken("pageToken873572522")
572    *           .setShowDeleted(true)
573    *           .build();
574    *   for (Service element : servicesClient.listServices(request).iterateAll()) {
575    *     // doThingsWith(element);
576    *   }
577    * }
578    * }</pre>
579    *
580    * @param request The request object containing all of the parameters for the API call.
581    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
582    */
listServices(ListServicesRequest request)583   public final ListServicesPagedResponse listServices(ListServicesRequest request) {
584     return listServicesPagedCallable().call(request);
585   }
586 
587   // AUTO-GENERATED DOCUMENTATION AND METHOD.
588   /**
589    * Lists Services.
590    *
591    * <p>Sample code:
592    *
593    * <pre>{@code
594    * // This snippet has been automatically generated and should be regarded as a code template only.
595    * // It will require modifications to work:
596    * // - It may require correct/in-range values for request initialization.
597    * // - It may require specifying regional endpoints when creating the service client as shown in
598    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
599    * try (ServicesClient servicesClient = ServicesClient.create()) {
600    *   ListServicesRequest request =
601    *       ListServicesRequest.newBuilder()
602    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
603    *           .setPageSize(883849137)
604    *           .setPageToken("pageToken873572522")
605    *           .setShowDeleted(true)
606    *           .build();
607    *   ApiFuture<Service> future = servicesClient.listServicesPagedCallable().futureCall(request);
608    *   // Do something.
609    *   for (Service element : future.get().iterateAll()) {
610    *     // doThingsWith(element);
611    *   }
612    * }
613    * }</pre>
614    */
615   public final UnaryCallable<ListServicesRequest, ListServicesPagedResponse>
listServicesPagedCallable()616       listServicesPagedCallable() {
617     return stub.listServicesPagedCallable();
618   }
619 
620   // AUTO-GENERATED DOCUMENTATION AND METHOD.
621   /**
622    * Lists Services.
623    *
624    * <p>Sample code:
625    *
626    * <pre>{@code
627    * // This snippet has been automatically generated and should be regarded as a code template only.
628    * // It will require modifications to work:
629    * // - It may require correct/in-range values for request initialization.
630    * // - It may require specifying regional endpoints when creating the service client as shown in
631    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
632    * try (ServicesClient servicesClient = ServicesClient.create()) {
633    *   ListServicesRequest request =
634    *       ListServicesRequest.newBuilder()
635    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
636    *           .setPageSize(883849137)
637    *           .setPageToken("pageToken873572522")
638    *           .setShowDeleted(true)
639    *           .build();
640    *   while (true) {
641    *     ListServicesResponse response = servicesClient.listServicesCallable().call(request);
642    *     for (Service element : response.getServicesList()) {
643    *       // doThingsWith(element);
644    *     }
645    *     String nextPageToken = response.getNextPageToken();
646    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
647    *       request = request.toBuilder().setPageToken(nextPageToken).build();
648    *     } else {
649    *       break;
650    *     }
651    *   }
652    * }
653    * }</pre>
654    */
listServicesCallable()655   public final UnaryCallable<ListServicesRequest, ListServicesResponse> listServicesCallable() {
656     return stub.listServicesCallable();
657   }
658 
659   // AUTO-GENERATED DOCUMENTATION AND METHOD.
660   /**
661    * Updates a Service.
662    *
663    * <p>Sample code:
664    *
665    * <pre>{@code
666    * // This snippet has been automatically generated and should be regarded as a code template only.
667    * // It will require modifications to work:
668    * // - It may require correct/in-range values for request initialization.
669    * // - It may require specifying regional endpoints when creating the service client as shown in
670    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
671    * try (ServicesClient servicesClient = ServicesClient.create()) {
672    *   Service service = Service.newBuilder().build();
673    *   Service response = servicesClient.updateServiceAsync(service).get();
674    * }
675    * }</pre>
676    *
677    * @param service Required. The Service to be updated.
678    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
679    */
updateServiceAsync(Service service)680   public final OperationFuture<Service, Service> updateServiceAsync(Service service) {
681     UpdateServiceRequest request = UpdateServiceRequest.newBuilder().setService(service).build();
682     return updateServiceAsync(request);
683   }
684 
685   // AUTO-GENERATED DOCUMENTATION AND METHOD.
686   /**
687    * Updates a Service.
688    *
689    * <p>Sample code:
690    *
691    * <pre>{@code
692    * // This snippet has been automatically generated and should be regarded as a code template only.
693    * // It will require modifications to work:
694    * // - It may require correct/in-range values for request initialization.
695    * // - It may require specifying regional endpoints when creating the service client as shown in
696    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
697    * try (ServicesClient servicesClient = ServicesClient.create()) {
698    *   UpdateServiceRequest request =
699    *       UpdateServiceRequest.newBuilder()
700    *           .setService(Service.newBuilder().build())
701    *           .setValidateOnly(true)
702    *           .setAllowMissing(true)
703    *           .build();
704    *   Service response = servicesClient.updateServiceAsync(request).get();
705    * }
706    * }</pre>
707    *
708    * @param request The request object containing all of the parameters for the API call.
709    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
710    */
updateServiceAsync(UpdateServiceRequest request)711   public final OperationFuture<Service, Service> updateServiceAsync(UpdateServiceRequest request) {
712     return updateServiceOperationCallable().futureCall(request);
713   }
714 
715   // AUTO-GENERATED DOCUMENTATION AND METHOD.
716   /**
717    * Updates a Service.
718    *
719    * <p>Sample code:
720    *
721    * <pre>{@code
722    * // This snippet has been automatically generated and should be regarded as a code template only.
723    * // It will require modifications to work:
724    * // - It may require correct/in-range values for request initialization.
725    * // - It may require specifying regional endpoints when creating the service client as shown in
726    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
727    * try (ServicesClient servicesClient = ServicesClient.create()) {
728    *   UpdateServiceRequest request =
729    *       UpdateServiceRequest.newBuilder()
730    *           .setService(Service.newBuilder().build())
731    *           .setValidateOnly(true)
732    *           .setAllowMissing(true)
733    *           .build();
734    *   OperationFuture<Service, Service> future =
735    *       servicesClient.updateServiceOperationCallable().futureCall(request);
736    *   // Do something.
737    *   Service response = future.get();
738    * }
739    * }</pre>
740    */
741   public final OperationCallable<UpdateServiceRequest, Service, Service>
updateServiceOperationCallable()742       updateServiceOperationCallable() {
743     return stub.updateServiceOperationCallable();
744   }
745 
746   // AUTO-GENERATED DOCUMENTATION AND METHOD.
747   /**
748    * Updates a Service.
749    *
750    * <p>Sample code:
751    *
752    * <pre>{@code
753    * // This snippet has been automatically generated and should be regarded as a code template only.
754    * // It will require modifications to work:
755    * // - It may require correct/in-range values for request initialization.
756    * // - It may require specifying regional endpoints when creating the service client as shown in
757    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
758    * try (ServicesClient servicesClient = ServicesClient.create()) {
759    *   UpdateServiceRequest request =
760    *       UpdateServiceRequest.newBuilder()
761    *           .setService(Service.newBuilder().build())
762    *           .setValidateOnly(true)
763    *           .setAllowMissing(true)
764    *           .build();
765    *   ApiFuture<Operation> future = servicesClient.updateServiceCallable().futureCall(request);
766    *   // Do something.
767    *   Operation response = future.get();
768    * }
769    * }</pre>
770    */
updateServiceCallable()771   public final UnaryCallable<UpdateServiceRequest, Operation> updateServiceCallable() {
772     return stub.updateServiceCallable();
773   }
774 
775   // AUTO-GENERATED DOCUMENTATION AND METHOD.
776   /**
777    * Deletes a Service. This will cause the Service to stop serving traffic and will delete all
778    * revisions.
779    *
780    * <p>Sample code:
781    *
782    * <pre>{@code
783    * // This snippet has been automatically generated and should be regarded as a code template only.
784    * // It will require modifications to work:
785    * // - It may require correct/in-range values for request initialization.
786    * // - It may require specifying regional endpoints when creating the service client as shown in
787    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
788    * try (ServicesClient servicesClient = ServicesClient.create()) {
789    *   ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]");
790    *   Service response = servicesClient.deleteServiceAsync(name).get();
791    * }
792    * }</pre>
793    *
794    * @param name Required. The full name of the Service. Format:
795    *     projects/{project}/locations/{location}/services/{service}, where {project} can be project
796    *     id or number.
797    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
798    */
deleteServiceAsync(ServiceName name)799   public final OperationFuture<Service, Service> deleteServiceAsync(ServiceName name) {
800     DeleteServiceRequest request =
801         DeleteServiceRequest.newBuilder().setName(name == null ? null : name.toString()).build();
802     return deleteServiceAsync(request);
803   }
804 
805   // AUTO-GENERATED DOCUMENTATION AND METHOD.
806   /**
807    * Deletes a Service. This will cause the Service to stop serving traffic and will delete all
808    * revisions.
809    *
810    * <p>Sample code:
811    *
812    * <pre>{@code
813    * // This snippet has been automatically generated and should be regarded as a code template only.
814    * // It will require modifications to work:
815    * // - It may require correct/in-range values for request initialization.
816    * // - It may require specifying regional endpoints when creating the service client as shown in
817    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
818    * try (ServicesClient servicesClient = ServicesClient.create()) {
819    *   String name = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString();
820    *   Service response = servicesClient.deleteServiceAsync(name).get();
821    * }
822    * }</pre>
823    *
824    * @param name Required. The full name of the Service. Format:
825    *     projects/{project}/locations/{location}/services/{service}, where {project} can be project
826    *     id or number.
827    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
828    */
deleteServiceAsync(String name)829   public final OperationFuture<Service, Service> deleteServiceAsync(String name) {
830     DeleteServiceRequest request = DeleteServiceRequest.newBuilder().setName(name).build();
831     return deleteServiceAsync(request);
832   }
833 
834   // AUTO-GENERATED DOCUMENTATION AND METHOD.
835   /**
836    * Deletes a Service. This will cause the Service to stop serving traffic and will delete all
837    * revisions.
838    *
839    * <p>Sample code:
840    *
841    * <pre>{@code
842    * // This snippet has been automatically generated and should be regarded as a code template only.
843    * // It will require modifications to work:
844    * // - It may require correct/in-range values for request initialization.
845    * // - It may require specifying regional endpoints when creating the service client as shown in
846    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
847    * try (ServicesClient servicesClient = ServicesClient.create()) {
848    *   DeleteServiceRequest request =
849    *       DeleteServiceRequest.newBuilder()
850    *           .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
851    *           .setValidateOnly(true)
852    *           .setEtag("etag3123477")
853    *           .build();
854    *   Service response = servicesClient.deleteServiceAsync(request).get();
855    * }
856    * }</pre>
857    *
858    * @param request The request object containing all of the parameters for the API call.
859    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
860    */
deleteServiceAsync(DeleteServiceRequest request)861   public final OperationFuture<Service, Service> deleteServiceAsync(DeleteServiceRequest request) {
862     return deleteServiceOperationCallable().futureCall(request);
863   }
864 
865   // AUTO-GENERATED DOCUMENTATION AND METHOD.
866   /**
867    * Deletes a Service. This will cause the Service to stop serving traffic and will delete all
868    * revisions.
869    *
870    * <p>Sample code:
871    *
872    * <pre>{@code
873    * // This snippet has been automatically generated and should be regarded as a code template only.
874    * // It will require modifications to work:
875    * // - It may require correct/in-range values for request initialization.
876    * // - It may require specifying regional endpoints when creating the service client as shown in
877    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
878    * try (ServicesClient servicesClient = ServicesClient.create()) {
879    *   DeleteServiceRequest request =
880    *       DeleteServiceRequest.newBuilder()
881    *           .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
882    *           .setValidateOnly(true)
883    *           .setEtag("etag3123477")
884    *           .build();
885    *   OperationFuture<Service, Service> future =
886    *       servicesClient.deleteServiceOperationCallable().futureCall(request);
887    *   // Do something.
888    *   Service response = future.get();
889    * }
890    * }</pre>
891    */
892   public final OperationCallable<DeleteServiceRequest, Service, Service>
deleteServiceOperationCallable()893       deleteServiceOperationCallable() {
894     return stub.deleteServiceOperationCallable();
895   }
896 
897   // AUTO-GENERATED DOCUMENTATION AND METHOD.
898   /**
899    * Deletes a Service. This will cause the Service to stop serving traffic and will delete all
900    * revisions.
901    *
902    * <p>Sample code:
903    *
904    * <pre>{@code
905    * // This snippet has been automatically generated and should be regarded as a code template only.
906    * // It will require modifications to work:
907    * // - It may require correct/in-range values for request initialization.
908    * // - It may require specifying regional endpoints when creating the service client as shown in
909    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
910    * try (ServicesClient servicesClient = ServicesClient.create()) {
911    *   DeleteServiceRequest request =
912    *       DeleteServiceRequest.newBuilder()
913    *           .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
914    *           .setValidateOnly(true)
915    *           .setEtag("etag3123477")
916    *           .build();
917    *   ApiFuture<Operation> future = servicesClient.deleteServiceCallable().futureCall(request);
918    *   // Do something.
919    *   Operation response = future.get();
920    * }
921    * }</pre>
922    */
deleteServiceCallable()923   public final UnaryCallable<DeleteServiceRequest, Operation> deleteServiceCallable() {
924     return stub.deleteServiceCallable();
925   }
926 
927   // AUTO-GENERATED DOCUMENTATION AND METHOD.
928   /**
929    * Gets the IAM Access Control policy currently in effect for the given Cloud Run Service. This
930    * result does not include any inherited policies.
931    *
932    * <p>Sample code:
933    *
934    * <pre>{@code
935    * // This snippet has been automatically generated and should be regarded as a code template only.
936    * // It will require modifications to work:
937    * // - It may require correct/in-range values for request initialization.
938    * // - It may require specifying regional endpoints when creating the service client as shown in
939    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
940    * try (ServicesClient servicesClient = ServicesClient.create()) {
941    *   GetIamPolicyRequest request =
942    *       GetIamPolicyRequest.newBuilder()
943    *           .setResource(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
944    *           .setOptions(GetPolicyOptions.newBuilder().build())
945    *           .build();
946    *   Policy response = servicesClient.getIamPolicy(request);
947    * }
948    * }</pre>
949    *
950    * @param request The request object containing all of the parameters for the API call.
951    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
952    */
getIamPolicy(GetIamPolicyRequest request)953   public final Policy getIamPolicy(GetIamPolicyRequest request) {
954     return getIamPolicyCallable().call(request);
955   }
956 
957   // AUTO-GENERATED DOCUMENTATION AND METHOD.
958   /**
959    * Gets the IAM Access Control policy currently in effect for the given Cloud Run Service. This
960    * result does not include any inherited policies.
961    *
962    * <p>Sample code:
963    *
964    * <pre>{@code
965    * // This snippet has been automatically generated and should be regarded as a code template only.
966    * // It will require modifications to work:
967    * // - It may require correct/in-range values for request initialization.
968    * // - It may require specifying regional endpoints when creating the service client as shown in
969    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
970    * try (ServicesClient servicesClient = ServicesClient.create()) {
971    *   GetIamPolicyRequest request =
972    *       GetIamPolicyRequest.newBuilder()
973    *           .setResource(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
974    *           .setOptions(GetPolicyOptions.newBuilder().build())
975    *           .build();
976    *   ApiFuture<Policy> future = servicesClient.getIamPolicyCallable().futureCall(request);
977    *   // Do something.
978    *   Policy response = future.get();
979    * }
980    * }</pre>
981    */
getIamPolicyCallable()982   public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
983     return stub.getIamPolicyCallable();
984   }
985 
986   // AUTO-GENERATED DOCUMENTATION AND METHOD.
987   /**
988    * Sets the IAM Access control policy for the specified Service. Overwrites any existing policy.
989    *
990    * <p>Sample code:
991    *
992    * <pre>{@code
993    * // This snippet has been automatically generated and should be regarded as a code template only.
994    * // It will require modifications to work:
995    * // - It may require correct/in-range values for request initialization.
996    * // - It may require specifying regional endpoints when creating the service client as shown in
997    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
998    * try (ServicesClient servicesClient = ServicesClient.create()) {
999    *   SetIamPolicyRequest request =
1000    *       SetIamPolicyRequest.newBuilder()
1001    *           .setResource(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
1002    *           .setPolicy(Policy.newBuilder().build())
1003    *           .setUpdateMask(FieldMask.newBuilder().build())
1004    *           .build();
1005    *   Policy response = servicesClient.setIamPolicy(request);
1006    * }
1007    * }</pre>
1008    *
1009    * @param request The request object containing all of the parameters for the API call.
1010    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1011    */
setIamPolicy(SetIamPolicyRequest request)1012   public final Policy setIamPolicy(SetIamPolicyRequest request) {
1013     return setIamPolicyCallable().call(request);
1014   }
1015 
1016   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1017   /**
1018    * Sets the IAM Access control policy for the specified Service. Overwrites any existing policy.
1019    *
1020    * <p>Sample code:
1021    *
1022    * <pre>{@code
1023    * // This snippet has been automatically generated and should be regarded as a code template only.
1024    * // It will require modifications to work:
1025    * // - It may require correct/in-range values for request initialization.
1026    * // - It may require specifying regional endpoints when creating the service client as shown in
1027    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1028    * try (ServicesClient servicesClient = ServicesClient.create()) {
1029    *   SetIamPolicyRequest request =
1030    *       SetIamPolicyRequest.newBuilder()
1031    *           .setResource(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
1032    *           .setPolicy(Policy.newBuilder().build())
1033    *           .setUpdateMask(FieldMask.newBuilder().build())
1034    *           .build();
1035    *   ApiFuture<Policy> future = servicesClient.setIamPolicyCallable().futureCall(request);
1036    *   // Do something.
1037    *   Policy response = future.get();
1038    * }
1039    * }</pre>
1040    */
setIamPolicyCallable()1041   public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
1042     return stub.setIamPolicyCallable();
1043   }
1044 
1045   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1046   /**
1047    * Returns permissions that a caller has on the specified Project.
1048    *
1049    * <p>There are no permissions required for making this API call.
1050    *
1051    * <p>Sample code:
1052    *
1053    * <pre>{@code
1054    * // This snippet has been automatically generated and should be regarded as a code template only.
1055    * // It will require modifications to work:
1056    * // - It may require correct/in-range values for request initialization.
1057    * // - It may require specifying regional endpoints when creating the service client as shown in
1058    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1059    * try (ServicesClient servicesClient = ServicesClient.create()) {
1060    *   TestIamPermissionsRequest request =
1061    *       TestIamPermissionsRequest.newBuilder()
1062    *           .setResource(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
1063    *           .addAllPermissions(new ArrayList<String>())
1064    *           .build();
1065    *   TestIamPermissionsResponse response = servicesClient.testIamPermissions(request);
1066    * }
1067    * }</pre>
1068    *
1069    * @param request The request object containing all of the parameters for the API call.
1070    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1071    */
testIamPermissions(TestIamPermissionsRequest request)1072   public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) {
1073     return testIamPermissionsCallable().call(request);
1074   }
1075 
1076   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1077   /**
1078    * Returns permissions that a caller has on the specified Project.
1079    *
1080    * <p>There are no permissions required for making this API call.
1081    *
1082    * <p>Sample code:
1083    *
1084    * <pre>{@code
1085    * // This snippet has been automatically generated and should be regarded as a code template only.
1086    * // It will require modifications to work:
1087    * // - It may require correct/in-range values for request initialization.
1088    * // - It may require specifying regional endpoints when creating the service client as shown in
1089    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1090    * try (ServicesClient servicesClient = ServicesClient.create()) {
1091    *   TestIamPermissionsRequest request =
1092    *       TestIamPermissionsRequest.newBuilder()
1093    *           .setResource(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
1094    *           .addAllPermissions(new ArrayList<String>())
1095    *           .build();
1096    *   ApiFuture<TestIamPermissionsResponse> future =
1097    *       servicesClient.testIamPermissionsCallable().futureCall(request);
1098    *   // Do something.
1099    *   TestIamPermissionsResponse response = future.get();
1100    * }
1101    * }</pre>
1102    */
1103   public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable()1104       testIamPermissionsCallable() {
1105     return stub.testIamPermissionsCallable();
1106   }
1107 
1108   @Override
close()1109   public final void close() {
1110     stub.close();
1111   }
1112 
1113   @Override
shutdown()1114   public void shutdown() {
1115     stub.shutdown();
1116   }
1117 
1118   @Override
isShutdown()1119   public boolean isShutdown() {
1120     return stub.isShutdown();
1121   }
1122 
1123   @Override
isTerminated()1124   public boolean isTerminated() {
1125     return stub.isTerminated();
1126   }
1127 
1128   @Override
shutdownNow()1129   public void shutdownNow() {
1130     stub.shutdownNow();
1131   }
1132 
1133   @Override
awaitTermination(long duration, TimeUnit unit)1134   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1135     return stub.awaitTermination(duration, unit);
1136   }
1137 
1138   public static class ListServicesPagedResponse
1139       extends AbstractPagedListResponse<
1140           ListServicesRequest,
1141           ListServicesResponse,
1142           Service,
1143           ListServicesPage,
1144           ListServicesFixedSizeCollection> {
1145 
createAsync( PageContext<ListServicesRequest, ListServicesResponse, Service> context, ApiFuture<ListServicesResponse> futureResponse)1146     public static ApiFuture<ListServicesPagedResponse> createAsync(
1147         PageContext<ListServicesRequest, ListServicesResponse, Service> context,
1148         ApiFuture<ListServicesResponse> futureResponse) {
1149       ApiFuture<ListServicesPage> futurePage =
1150           ListServicesPage.createEmptyPage().createPageAsync(context, futureResponse);
1151       return ApiFutures.transform(
1152           futurePage,
1153           input -> new ListServicesPagedResponse(input),
1154           MoreExecutors.directExecutor());
1155     }
1156 
ListServicesPagedResponse(ListServicesPage page)1157     private ListServicesPagedResponse(ListServicesPage page) {
1158       super(page, ListServicesFixedSizeCollection.createEmptyCollection());
1159     }
1160   }
1161 
1162   public static class ListServicesPage
1163       extends AbstractPage<ListServicesRequest, ListServicesResponse, Service, ListServicesPage> {
1164 
ListServicesPage( PageContext<ListServicesRequest, ListServicesResponse, Service> context, ListServicesResponse response)1165     private ListServicesPage(
1166         PageContext<ListServicesRequest, ListServicesResponse, Service> context,
1167         ListServicesResponse response) {
1168       super(context, response);
1169     }
1170 
createEmptyPage()1171     private static ListServicesPage createEmptyPage() {
1172       return new ListServicesPage(null, null);
1173     }
1174 
1175     @Override
createPage( PageContext<ListServicesRequest, ListServicesResponse, Service> context, ListServicesResponse response)1176     protected ListServicesPage createPage(
1177         PageContext<ListServicesRequest, ListServicesResponse, Service> context,
1178         ListServicesResponse response) {
1179       return new ListServicesPage(context, response);
1180     }
1181 
1182     @Override
createPageAsync( PageContext<ListServicesRequest, ListServicesResponse, Service> context, ApiFuture<ListServicesResponse> futureResponse)1183     public ApiFuture<ListServicesPage> createPageAsync(
1184         PageContext<ListServicesRequest, ListServicesResponse, Service> context,
1185         ApiFuture<ListServicesResponse> futureResponse) {
1186       return super.createPageAsync(context, futureResponse);
1187     }
1188   }
1189 
1190   public static class ListServicesFixedSizeCollection
1191       extends AbstractFixedSizeCollection<
1192           ListServicesRequest,
1193           ListServicesResponse,
1194           Service,
1195           ListServicesPage,
1196           ListServicesFixedSizeCollection> {
1197 
ListServicesFixedSizeCollection(List<ListServicesPage> pages, int collectionSize)1198     private ListServicesFixedSizeCollection(List<ListServicesPage> pages, int collectionSize) {
1199       super(pages, collectionSize);
1200     }
1201 
createEmptyCollection()1202     private static ListServicesFixedSizeCollection createEmptyCollection() {
1203       return new ListServicesFixedSizeCollection(null, 0);
1204     }
1205 
1206     @Override
createCollection( List<ListServicesPage> pages, int collectionSize)1207     protected ListServicesFixedSizeCollection createCollection(
1208         List<ListServicesPage> pages, int collectionSize) {
1209       return new ListServicesFixedSizeCollection(pages, collectionSize);
1210     }
1211   }
1212 }
1213