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