• 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.RegionSslCertificatesStub;
31 import com.google.cloud.compute.v1.stub.RegionSslCertificatesStubSettings;
32 import com.google.common.util.concurrent.MoreExecutors;
33 import java.io.IOException;
34 import java.util.List;
35 import java.util.concurrent.TimeUnit;
36 import javax.annotation.Generated;
37 
38 // AUTO-GENERATED DOCUMENTATION AND CLASS.
39 /**
40  * Service Description: The RegionSslCertificates API.
41  *
42  * <p>This class provides the ability to make remote calls to the backing service through method
43  * calls that map to API methods. Sample code to get started:
44  *
45  * <pre>{@code
46  * // This snippet has been automatically generated and should be regarded as a code template only.
47  * // It will require modifications to work:
48  * // - It may require correct/in-range values for request initialization.
49  * // - It may require specifying regional endpoints when creating the service client as shown in
50  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
51  * try (RegionSslCertificatesClient regionSslCertificatesClient =
52  *     RegionSslCertificatesClient.create()) {
53  *   String project = "project-309310695";
54  *   String region = "region-934795532";
55  *   String sslCertificate = "sslCertificate-1304941589";
56  *   SslCertificate response = regionSslCertificatesClient.get(project, region, sslCertificate);
57  * }
58  * }</pre>
59  *
60  * <p>Note: close() needs to be called on the RegionSslCertificatesClient object to clean up
61  * resources such as threads. In the example above, try-with-resources is used, which automatically
62  * calls close().
63  *
64  * <p>The surface of this class includes several types of Java methods for each of the API's
65  * methods:
66  *
67  * <ol>
68  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
69  *       converted into function parameters. It may be the case that not all fields are available as
70  *       parameters, and not every API method will have a flattened method entry point.
71  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
72  *       which must be constructed before the call. Not every API method will have a request object
73  *       method.
74  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
75  *       callable object, which can be used to initiate calls to the service.
76  * </ol>
77  *
78  * <p>See the individual methods for example code.
79  *
80  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
81  * these names, this class includes a format method for each type of name, and additionally a parse
82  * method to extract the individual identifiers contained within names that are returned.
83  *
84  * <p>This class can be customized by passing in a custom instance of RegionSslCertificatesSettings
85  * to create(). For example:
86  *
87  * <p>To customize credentials:
88  *
89  * <pre>{@code
90  * // This snippet has been automatically generated and should be regarded as a code template only.
91  * // It will require modifications to work:
92  * // - It may require correct/in-range values for request initialization.
93  * // - It may require specifying regional endpoints when creating the service client as shown in
94  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
95  * RegionSslCertificatesSettings regionSslCertificatesSettings =
96  *     RegionSslCertificatesSettings.newBuilder()
97  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
98  *         .build();
99  * RegionSslCertificatesClient regionSslCertificatesClient =
100  *     RegionSslCertificatesClient.create(regionSslCertificatesSettings);
101  * }</pre>
102  *
103  * <p>To customize the endpoint:
104  *
105  * <pre>{@code
106  * // This snippet has been automatically generated and should be regarded as a code template only.
107  * // It will require modifications to work:
108  * // - It may require correct/in-range values for request initialization.
109  * // - It may require specifying regional endpoints when creating the service client as shown in
110  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
111  * RegionSslCertificatesSettings regionSslCertificatesSettings =
112  *     RegionSslCertificatesSettings.newBuilder().setEndpoint(myEndpoint).build();
113  * RegionSslCertificatesClient regionSslCertificatesClient =
114  *     RegionSslCertificatesClient.create(regionSslCertificatesSettings);
115  * }</pre>
116  *
117  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
118  */
119 @Generated("by gapic-generator-java")
120 public class RegionSslCertificatesClient implements BackgroundResource {
121   private final RegionSslCertificatesSettings settings;
122   private final RegionSslCertificatesStub stub;
123 
124   /** Constructs an instance of RegionSslCertificatesClient with default settings. */
create()125   public static final RegionSslCertificatesClient create() throws IOException {
126     return create(RegionSslCertificatesSettings.newBuilder().build());
127   }
128 
129   /**
130    * Constructs an instance of RegionSslCertificatesClient, using the given settings. The channels
131    * are created based on the settings passed in, or defaults for any settings that are not set.
132    */
create(RegionSslCertificatesSettings settings)133   public static final RegionSslCertificatesClient create(RegionSslCertificatesSettings settings)
134       throws IOException {
135     return new RegionSslCertificatesClient(settings);
136   }
137 
138   /**
139    * Constructs an instance of RegionSslCertificatesClient, using the given stub for making calls.
140    * This is for advanced usage - prefer using create(RegionSslCertificatesSettings).
141    */
create(RegionSslCertificatesStub stub)142   public static final RegionSslCertificatesClient create(RegionSslCertificatesStub stub) {
143     return new RegionSslCertificatesClient(stub);
144   }
145 
146   /**
147    * Constructs an instance of RegionSslCertificatesClient, using the given settings. This is
148    * protected so that it is easy to make a subclass, but otherwise, the static factory methods
149    * should be preferred.
150    */
RegionSslCertificatesClient(RegionSslCertificatesSettings settings)151   protected RegionSslCertificatesClient(RegionSslCertificatesSettings settings) throws IOException {
152     this.settings = settings;
153     this.stub = ((RegionSslCertificatesStubSettings) settings.getStubSettings()).createStub();
154   }
155 
RegionSslCertificatesClient(RegionSslCertificatesStub stub)156   protected RegionSslCertificatesClient(RegionSslCertificatesStub stub) {
157     this.settings = null;
158     this.stub = stub;
159   }
160 
getSettings()161   public final RegionSslCertificatesSettings getSettings() {
162     return settings;
163   }
164 
getStub()165   public RegionSslCertificatesStub getStub() {
166     return stub;
167   }
168 
169   // AUTO-GENERATED DOCUMENTATION AND METHOD.
170   /**
171    * Deletes the specified SslCertificate resource in the region.
172    *
173    * <p>Sample code:
174    *
175    * <pre>{@code
176    * // This snippet has been automatically generated and should be regarded as a code template only.
177    * // It will require modifications to work:
178    * // - It may require correct/in-range values for request initialization.
179    * // - It may require specifying regional endpoints when creating the service client as shown in
180    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
181    * try (RegionSslCertificatesClient regionSslCertificatesClient =
182    *     RegionSslCertificatesClient.create()) {
183    *   String project = "project-309310695";
184    *   String region = "region-934795532";
185    *   String sslCertificate = "sslCertificate-1304941589";
186    *   Operation response =
187    *       regionSslCertificatesClient.deleteAsync(project, region, sslCertificate).get();
188    * }
189    * }</pre>
190    *
191    * @param project Project ID for this request.
192    * @param region Name of the region scoping this request.
193    * @param sslCertificate Name of the SslCertificate resource to delete.
194    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
195    */
deleteAsync( String project, String region, String sslCertificate)196   public final OperationFuture<Operation, Operation> deleteAsync(
197       String project, String region, String sslCertificate) {
198     DeleteRegionSslCertificateRequest request =
199         DeleteRegionSslCertificateRequest.newBuilder()
200             .setProject(project)
201             .setRegion(region)
202             .setSslCertificate(sslCertificate)
203             .build();
204     return deleteAsync(request);
205   }
206 
207   // AUTO-GENERATED DOCUMENTATION AND METHOD.
208   /**
209    * Deletes the specified SslCertificate resource in the region.
210    *
211    * <p>Sample code:
212    *
213    * <pre>{@code
214    * // This snippet has been automatically generated and should be regarded as a code template only.
215    * // It will require modifications to work:
216    * // - It may require correct/in-range values for request initialization.
217    * // - It may require specifying regional endpoints when creating the service client as shown in
218    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
219    * try (RegionSslCertificatesClient regionSslCertificatesClient =
220    *     RegionSslCertificatesClient.create()) {
221    *   DeleteRegionSslCertificateRequest request =
222    *       DeleteRegionSslCertificateRequest.newBuilder()
223    *           .setProject("project-309310695")
224    *           .setRegion("region-934795532")
225    *           .setRequestId("requestId693933066")
226    *           .setSslCertificate("sslCertificate-1304941589")
227    *           .build();
228    *   Operation response = regionSslCertificatesClient.deleteAsync(request).get();
229    * }
230    * }</pre>
231    *
232    * @param request The request object containing all of the parameters for the API call.
233    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
234    */
235   @BetaApi(
236       "The surface for long-running operations is not stable yet and may change in the future.")
deleteAsync( DeleteRegionSslCertificateRequest request)237   public final OperationFuture<Operation, Operation> deleteAsync(
238       DeleteRegionSslCertificateRequest request) {
239     return deleteOperationCallable().futureCall(request);
240   }
241 
242   // AUTO-GENERATED DOCUMENTATION AND METHOD.
243   /**
244    * Deletes the specified SslCertificate resource in the region.
245    *
246    * <p>Sample code:
247    *
248    * <pre>{@code
249    * // This snippet has been automatically generated and should be regarded as a code template only.
250    * // It will require modifications to work:
251    * // - It may require correct/in-range values for request initialization.
252    * // - It may require specifying regional endpoints when creating the service client as shown in
253    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
254    * try (RegionSslCertificatesClient regionSslCertificatesClient =
255    *     RegionSslCertificatesClient.create()) {
256    *   DeleteRegionSslCertificateRequest request =
257    *       DeleteRegionSslCertificateRequest.newBuilder()
258    *           .setProject("project-309310695")
259    *           .setRegion("region-934795532")
260    *           .setRequestId("requestId693933066")
261    *           .setSslCertificate("sslCertificate-1304941589")
262    *           .build();
263    *   OperationFuture<Operation, Operation> future =
264    *       regionSslCertificatesClient.deleteOperationCallable().futureCall(request);
265    *   // Do something.
266    *   Operation response = future.get();
267    * }
268    * }</pre>
269    */
270   public final OperationCallable<DeleteRegionSslCertificateRequest, Operation, Operation>
deleteOperationCallable()271       deleteOperationCallable() {
272     return stub.deleteOperationCallable();
273   }
274 
275   // AUTO-GENERATED DOCUMENTATION AND METHOD.
276   /**
277    * Deletes the specified SslCertificate resource in the region.
278    *
279    * <p>Sample code:
280    *
281    * <pre>{@code
282    * // This snippet has been automatically generated and should be regarded as a code template only.
283    * // It will require modifications to work:
284    * // - It may require correct/in-range values for request initialization.
285    * // - It may require specifying regional endpoints when creating the service client as shown in
286    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
287    * try (RegionSslCertificatesClient regionSslCertificatesClient =
288    *     RegionSslCertificatesClient.create()) {
289    *   DeleteRegionSslCertificateRequest request =
290    *       DeleteRegionSslCertificateRequest.newBuilder()
291    *           .setProject("project-309310695")
292    *           .setRegion("region-934795532")
293    *           .setRequestId("requestId693933066")
294    *           .setSslCertificate("sslCertificate-1304941589")
295    *           .build();
296    *   ApiFuture<Operation> future =
297    *       regionSslCertificatesClient.deleteCallable().futureCall(request);
298    *   // Do something.
299    *   Operation response = future.get();
300    * }
301    * }</pre>
302    */
deleteCallable()303   public final UnaryCallable<DeleteRegionSslCertificateRequest, Operation> deleteCallable() {
304     return stub.deleteCallable();
305   }
306 
307   // AUTO-GENERATED DOCUMENTATION AND METHOD.
308   /**
309    * Returns the specified SslCertificate resource in the specified region. Get a list of available
310    * SSL certificates by making a list() request.
311    *
312    * <p>Sample code:
313    *
314    * <pre>{@code
315    * // This snippet has been automatically generated and should be regarded as a code template only.
316    * // It will require modifications to work:
317    * // - It may require correct/in-range values for request initialization.
318    * // - It may require specifying regional endpoints when creating the service client as shown in
319    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
320    * try (RegionSslCertificatesClient regionSslCertificatesClient =
321    *     RegionSslCertificatesClient.create()) {
322    *   String project = "project-309310695";
323    *   String region = "region-934795532";
324    *   String sslCertificate = "sslCertificate-1304941589";
325    *   SslCertificate response = regionSslCertificatesClient.get(project, region, sslCertificate);
326    * }
327    * }</pre>
328    *
329    * @param project Project ID for this request.
330    * @param region Name of the region scoping this request.
331    * @param sslCertificate Name of the SslCertificate resource to return.
332    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
333    */
get(String project, String region, String sslCertificate)334   public final SslCertificate get(String project, String region, String sslCertificate) {
335     GetRegionSslCertificateRequest request =
336         GetRegionSslCertificateRequest.newBuilder()
337             .setProject(project)
338             .setRegion(region)
339             .setSslCertificate(sslCertificate)
340             .build();
341     return get(request);
342   }
343 
344   // AUTO-GENERATED DOCUMENTATION AND METHOD.
345   /**
346    * Returns the specified SslCertificate resource in the specified region. Get a list of available
347    * SSL certificates by making a list() request.
348    *
349    * <p>Sample code:
350    *
351    * <pre>{@code
352    * // This snippet has been automatically generated and should be regarded as a code template only.
353    * // It will require modifications to work:
354    * // - It may require correct/in-range values for request initialization.
355    * // - It may require specifying regional endpoints when creating the service client as shown in
356    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
357    * try (RegionSslCertificatesClient regionSslCertificatesClient =
358    *     RegionSslCertificatesClient.create()) {
359    *   GetRegionSslCertificateRequest request =
360    *       GetRegionSslCertificateRequest.newBuilder()
361    *           .setProject("project-309310695")
362    *           .setRegion("region-934795532")
363    *           .setSslCertificate("sslCertificate-1304941589")
364    *           .build();
365    *   SslCertificate response = regionSslCertificatesClient.get(request);
366    * }
367    * }</pre>
368    *
369    * @param request The request object containing all of the parameters for the API call.
370    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
371    */
get(GetRegionSslCertificateRequest request)372   public final SslCertificate get(GetRegionSslCertificateRequest request) {
373     return getCallable().call(request);
374   }
375 
376   // AUTO-GENERATED DOCUMENTATION AND METHOD.
377   /**
378    * Returns the specified SslCertificate resource in the specified region. Get a list of available
379    * SSL certificates by making a list() request.
380    *
381    * <p>Sample code:
382    *
383    * <pre>{@code
384    * // This snippet has been automatically generated and should be regarded as a code template only.
385    * // It will require modifications to work:
386    * // - It may require correct/in-range values for request initialization.
387    * // - It may require specifying regional endpoints when creating the service client as shown in
388    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
389    * try (RegionSslCertificatesClient regionSslCertificatesClient =
390    *     RegionSslCertificatesClient.create()) {
391    *   GetRegionSslCertificateRequest request =
392    *       GetRegionSslCertificateRequest.newBuilder()
393    *           .setProject("project-309310695")
394    *           .setRegion("region-934795532")
395    *           .setSslCertificate("sslCertificate-1304941589")
396    *           .build();
397    *   ApiFuture<SslCertificate> future =
398    *       regionSslCertificatesClient.getCallable().futureCall(request);
399    *   // Do something.
400    *   SslCertificate response = future.get();
401    * }
402    * }</pre>
403    */
getCallable()404   public final UnaryCallable<GetRegionSslCertificateRequest, SslCertificate> getCallable() {
405     return stub.getCallable();
406   }
407 
408   // AUTO-GENERATED DOCUMENTATION AND METHOD.
409   /**
410    * Creates a SslCertificate resource in the specified project and region using the data included
411    * in the request
412    *
413    * <p>Sample code:
414    *
415    * <pre>{@code
416    * // This snippet has been automatically generated and should be regarded as a code template only.
417    * // It will require modifications to work:
418    * // - It may require correct/in-range values for request initialization.
419    * // - It may require specifying regional endpoints when creating the service client as shown in
420    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
421    * try (RegionSslCertificatesClient regionSslCertificatesClient =
422    *     RegionSslCertificatesClient.create()) {
423    *   String project = "project-309310695";
424    *   String region = "region-934795532";
425    *   SslCertificate sslCertificateResource = SslCertificate.newBuilder().build();
426    *   Operation response =
427    *       regionSslCertificatesClient.insertAsync(project, region, sslCertificateResource).get();
428    * }
429    * }</pre>
430    *
431    * @param project Project ID for this request.
432    * @param region Name of the region scoping this request.
433    * @param sslCertificateResource The body resource for this request
434    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
435    */
insertAsync( String project, String region, SslCertificate sslCertificateResource)436   public final OperationFuture<Operation, Operation> insertAsync(
437       String project, String region, SslCertificate sslCertificateResource) {
438     InsertRegionSslCertificateRequest request =
439         InsertRegionSslCertificateRequest.newBuilder()
440             .setProject(project)
441             .setRegion(region)
442             .setSslCertificateResource(sslCertificateResource)
443             .build();
444     return insertAsync(request);
445   }
446 
447   // AUTO-GENERATED DOCUMENTATION AND METHOD.
448   /**
449    * Creates a SslCertificate resource in the specified project and region using the data included
450    * in the request
451    *
452    * <p>Sample code:
453    *
454    * <pre>{@code
455    * // This snippet has been automatically generated and should be regarded as a code template only.
456    * // It will require modifications to work:
457    * // - It may require correct/in-range values for request initialization.
458    * // - It may require specifying regional endpoints when creating the service client as shown in
459    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
460    * try (RegionSslCertificatesClient regionSslCertificatesClient =
461    *     RegionSslCertificatesClient.create()) {
462    *   InsertRegionSslCertificateRequest request =
463    *       InsertRegionSslCertificateRequest.newBuilder()
464    *           .setProject("project-309310695")
465    *           .setRegion("region-934795532")
466    *           .setRequestId("requestId693933066")
467    *           .setSslCertificateResource(SslCertificate.newBuilder().build())
468    *           .build();
469    *   Operation response = regionSslCertificatesClient.insertAsync(request).get();
470    * }
471    * }</pre>
472    *
473    * @param request The request object containing all of the parameters for the API call.
474    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
475    */
476   @BetaApi(
477       "The surface for long-running operations is not stable yet and may change in the future.")
insertAsync( InsertRegionSslCertificateRequest request)478   public final OperationFuture<Operation, Operation> insertAsync(
479       InsertRegionSslCertificateRequest request) {
480     return insertOperationCallable().futureCall(request);
481   }
482 
483   // AUTO-GENERATED DOCUMENTATION AND METHOD.
484   /**
485    * Creates a SslCertificate resource in the specified project and region using the data included
486    * in the request
487    *
488    * <p>Sample code:
489    *
490    * <pre>{@code
491    * // This snippet has been automatically generated and should be regarded as a code template only.
492    * // It will require modifications to work:
493    * // - It may require correct/in-range values for request initialization.
494    * // - It may require specifying regional endpoints when creating the service client as shown in
495    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
496    * try (RegionSslCertificatesClient regionSslCertificatesClient =
497    *     RegionSslCertificatesClient.create()) {
498    *   InsertRegionSslCertificateRequest request =
499    *       InsertRegionSslCertificateRequest.newBuilder()
500    *           .setProject("project-309310695")
501    *           .setRegion("region-934795532")
502    *           .setRequestId("requestId693933066")
503    *           .setSslCertificateResource(SslCertificate.newBuilder().build())
504    *           .build();
505    *   OperationFuture<Operation, Operation> future =
506    *       regionSslCertificatesClient.insertOperationCallable().futureCall(request);
507    *   // Do something.
508    *   Operation response = future.get();
509    * }
510    * }</pre>
511    */
512   public final OperationCallable<InsertRegionSslCertificateRequest, Operation, Operation>
insertOperationCallable()513       insertOperationCallable() {
514     return stub.insertOperationCallable();
515   }
516 
517   // AUTO-GENERATED DOCUMENTATION AND METHOD.
518   /**
519    * Creates a SslCertificate resource in the specified project and region using the data included
520    * in the request
521    *
522    * <p>Sample code:
523    *
524    * <pre>{@code
525    * // This snippet has been automatically generated and should be regarded as a code template only.
526    * // It will require modifications to work:
527    * // - It may require correct/in-range values for request initialization.
528    * // - It may require specifying regional endpoints when creating the service client as shown in
529    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
530    * try (RegionSslCertificatesClient regionSslCertificatesClient =
531    *     RegionSslCertificatesClient.create()) {
532    *   InsertRegionSslCertificateRequest request =
533    *       InsertRegionSslCertificateRequest.newBuilder()
534    *           .setProject("project-309310695")
535    *           .setRegion("region-934795532")
536    *           .setRequestId("requestId693933066")
537    *           .setSslCertificateResource(SslCertificate.newBuilder().build())
538    *           .build();
539    *   ApiFuture<Operation> future =
540    *       regionSslCertificatesClient.insertCallable().futureCall(request);
541    *   // Do something.
542    *   Operation response = future.get();
543    * }
544    * }</pre>
545    */
insertCallable()546   public final UnaryCallable<InsertRegionSslCertificateRequest, Operation> insertCallable() {
547     return stub.insertCallable();
548   }
549 
550   // AUTO-GENERATED DOCUMENTATION AND METHOD.
551   /**
552    * Retrieves the list of SslCertificate resources available to the specified project in the
553    * specified region.
554    *
555    * <p>Sample code:
556    *
557    * <pre>{@code
558    * // This snippet has been automatically generated and should be regarded as a code template only.
559    * // It will require modifications to work:
560    * // - It may require correct/in-range values for request initialization.
561    * // - It may require specifying regional endpoints when creating the service client as shown in
562    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
563    * try (RegionSslCertificatesClient regionSslCertificatesClient =
564    *     RegionSslCertificatesClient.create()) {
565    *   String project = "project-309310695";
566    *   String region = "region-934795532";
567    *   for (SslCertificate element :
568    *       regionSslCertificatesClient.list(project, region).iterateAll()) {
569    *     // doThingsWith(element);
570    *   }
571    * }
572    * }</pre>
573    *
574    * @param project Project ID for this request.
575    * @param region Name of the region scoping this request.
576    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
577    */
list(String project, String region)578   public final ListPagedResponse list(String project, String region) {
579     ListRegionSslCertificatesRequest request =
580         ListRegionSslCertificatesRequest.newBuilder().setProject(project).setRegion(region).build();
581     return list(request);
582   }
583 
584   // AUTO-GENERATED DOCUMENTATION AND METHOD.
585   /**
586    * Retrieves the list of SslCertificate resources available to the specified project in the
587    * specified region.
588    *
589    * <p>Sample code:
590    *
591    * <pre>{@code
592    * // This snippet has been automatically generated and should be regarded as a code template only.
593    * // It will require modifications to work:
594    * // - It may require correct/in-range values for request initialization.
595    * // - It may require specifying regional endpoints when creating the service client as shown in
596    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
597    * try (RegionSslCertificatesClient regionSslCertificatesClient =
598    *     RegionSslCertificatesClient.create()) {
599    *   ListRegionSslCertificatesRequest request =
600    *       ListRegionSslCertificatesRequest.newBuilder()
601    *           .setFilter("filter-1274492040")
602    *           .setMaxResults(1128457243)
603    *           .setOrderBy("orderBy-1207110587")
604    *           .setPageToken("pageToken873572522")
605    *           .setProject("project-309310695")
606    *           .setRegion("region-934795532")
607    *           .setReturnPartialSuccess(true)
608    *           .build();
609    *   for (SslCertificate element : regionSslCertificatesClient.list(request).iterateAll()) {
610    *     // doThingsWith(element);
611    *   }
612    * }
613    * }</pre>
614    *
615    * @param request The request object containing all of the parameters for the API call.
616    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
617    */
list(ListRegionSslCertificatesRequest request)618   public final ListPagedResponse list(ListRegionSslCertificatesRequest request) {
619     return listPagedCallable().call(request);
620   }
621 
622   // AUTO-GENERATED DOCUMENTATION AND METHOD.
623   /**
624    * Retrieves the list of SslCertificate resources available to the specified project in the
625    * specified region.
626    *
627    * <p>Sample code:
628    *
629    * <pre>{@code
630    * // This snippet has been automatically generated and should be regarded as a code template only.
631    * // It will require modifications to work:
632    * // - It may require correct/in-range values for request initialization.
633    * // - It may require specifying regional endpoints when creating the service client as shown in
634    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
635    * try (RegionSslCertificatesClient regionSslCertificatesClient =
636    *     RegionSslCertificatesClient.create()) {
637    *   ListRegionSslCertificatesRequest request =
638    *       ListRegionSslCertificatesRequest.newBuilder()
639    *           .setFilter("filter-1274492040")
640    *           .setMaxResults(1128457243)
641    *           .setOrderBy("orderBy-1207110587")
642    *           .setPageToken("pageToken873572522")
643    *           .setProject("project-309310695")
644    *           .setRegion("region-934795532")
645    *           .setReturnPartialSuccess(true)
646    *           .build();
647    *   ApiFuture<SslCertificate> future =
648    *       regionSslCertificatesClient.listPagedCallable().futureCall(request);
649    *   // Do something.
650    *   for (SslCertificate element : future.get().iterateAll()) {
651    *     // doThingsWith(element);
652    *   }
653    * }
654    * }</pre>
655    */
656   public final UnaryCallable<ListRegionSslCertificatesRequest, ListPagedResponse>
listPagedCallable()657       listPagedCallable() {
658     return stub.listPagedCallable();
659   }
660 
661   // AUTO-GENERATED DOCUMENTATION AND METHOD.
662   /**
663    * Retrieves the list of SslCertificate resources available to the specified project in the
664    * specified region.
665    *
666    * <p>Sample code:
667    *
668    * <pre>{@code
669    * // This snippet has been automatically generated and should be regarded as a code template only.
670    * // It will require modifications to work:
671    * // - It may require correct/in-range values for request initialization.
672    * // - It may require specifying regional endpoints when creating the service client as shown in
673    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
674    * try (RegionSslCertificatesClient regionSslCertificatesClient =
675    *     RegionSslCertificatesClient.create()) {
676    *   ListRegionSslCertificatesRequest request =
677    *       ListRegionSslCertificatesRequest.newBuilder()
678    *           .setFilter("filter-1274492040")
679    *           .setMaxResults(1128457243)
680    *           .setOrderBy("orderBy-1207110587")
681    *           .setPageToken("pageToken873572522")
682    *           .setProject("project-309310695")
683    *           .setRegion("region-934795532")
684    *           .setReturnPartialSuccess(true)
685    *           .build();
686    *   while (true) {
687    *     SslCertificateList response = regionSslCertificatesClient.listCallable().call(request);
688    *     for (SslCertificate element : response.getItemsList()) {
689    *       // doThingsWith(element);
690    *     }
691    *     String nextPageToken = response.getNextPageToken();
692    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
693    *       request = request.toBuilder().setPageToken(nextPageToken).build();
694    *     } else {
695    *       break;
696    *     }
697    *   }
698    * }
699    * }</pre>
700    */
listCallable()701   public final UnaryCallable<ListRegionSslCertificatesRequest, SslCertificateList> listCallable() {
702     return stub.listCallable();
703   }
704 
705   @Override
close()706   public final void close() {
707     stub.close();
708   }
709 
710   @Override
shutdown()711   public void shutdown() {
712     stub.shutdown();
713   }
714 
715   @Override
isShutdown()716   public boolean isShutdown() {
717     return stub.isShutdown();
718   }
719 
720   @Override
isTerminated()721   public boolean isTerminated() {
722     return stub.isTerminated();
723   }
724 
725   @Override
shutdownNow()726   public void shutdownNow() {
727     stub.shutdownNow();
728   }
729 
730   @Override
awaitTermination(long duration, TimeUnit unit)731   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
732     return stub.awaitTermination(duration, unit);
733   }
734 
735   public static class ListPagedResponse
736       extends AbstractPagedListResponse<
737           ListRegionSslCertificatesRequest,
738           SslCertificateList,
739           SslCertificate,
740           ListPage,
741           ListFixedSizeCollection> {
742 
createAsync( PageContext<ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate> context, ApiFuture<SslCertificateList> futureResponse)743     public static ApiFuture<ListPagedResponse> createAsync(
744         PageContext<ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate> context,
745         ApiFuture<SslCertificateList> futureResponse) {
746       ApiFuture<ListPage> futurePage =
747           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
748       return ApiFutures.transform(
749           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
750     }
751 
ListPagedResponse(ListPage page)752     private ListPagedResponse(ListPage page) {
753       super(page, ListFixedSizeCollection.createEmptyCollection());
754     }
755   }
756 
757   public static class ListPage
758       extends AbstractPage<
759           ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate, ListPage> {
760 
ListPage( PageContext<ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate> context, SslCertificateList response)761     private ListPage(
762         PageContext<ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate> context,
763         SslCertificateList response) {
764       super(context, response);
765     }
766 
createEmptyPage()767     private static ListPage createEmptyPage() {
768       return new ListPage(null, null);
769     }
770 
771     @Override
createPage( PageContext<ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate> context, SslCertificateList response)772     protected ListPage createPage(
773         PageContext<ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate> context,
774         SslCertificateList response) {
775       return new ListPage(context, response);
776     }
777 
778     @Override
createPageAsync( PageContext<ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate> context, ApiFuture<SslCertificateList> futureResponse)779     public ApiFuture<ListPage> createPageAsync(
780         PageContext<ListRegionSslCertificatesRequest, SslCertificateList, SslCertificate> context,
781         ApiFuture<SslCertificateList> futureResponse) {
782       return super.createPageAsync(context, futureResponse);
783     }
784   }
785 
786   public static class ListFixedSizeCollection
787       extends AbstractFixedSizeCollection<
788           ListRegionSslCertificatesRequest,
789           SslCertificateList,
790           SslCertificate,
791           ListPage,
792           ListFixedSizeCollection> {
793 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)794     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
795       super(pages, collectionSize);
796     }
797 
createEmptyCollection()798     private static ListFixedSizeCollection createEmptyCollection() {
799       return new ListFixedSizeCollection(null, 0);
800     }
801 
802     @Override
createCollection(List<ListPage> pages, int collectionSize)803     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
804       return new ListFixedSizeCollection(pages, collectionSize);
805     }
806   }
807 }
808