• 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.dialogflow.v2;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.gax.core.BackgroundResource;
22 import com.google.api.gax.paging.AbstractFixedSizeCollection;
23 import com.google.api.gax.paging.AbstractPage;
24 import com.google.api.gax.paging.AbstractPagedListResponse;
25 import com.google.api.gax.rpc.PageContext;
26 import com.google.api.gax.rpc.UnaryCallable;
27 import com.google.cloud.dialogflow.v2.stub.FulfillmentsStub;
28 import com.google.cloud.dialogflow.v2.stub.FulfillmentsStubSettings;
29 import com.google.cloud.location.GetLocationRequest;
30 import com.google.cloud.location.ListLocationsRequest;
31 import com.google.cloud.location.ListLocationsResponse;
32 import com.google.cloud.location.Location;
33 import com.google.common.util.concurrent.MoreExecutors;
34 import com.google.protobuf.FieldMask;
35 import java.io.IOException;
36 import java.util.List;
37 import java.util.concurrent.TimeUnit;
38 import javax.annotation.Generated;
39 
40 // AUTO-GENERATED DOCUMENTATION AND CLASS.
41 /**
42  * Service Description: Service for managing [Fulfillments][google.cloud.dialogflow.v2.Fulfillment].
43  *
44  * <p>This class provides the ability to make remote calls to the backing service through method
45  * calls that map to API methods. Sample code to get started:
46  *
47  * <pre>{@code
48  * // This snippet has been automatically generated and should be regarded as a code template only.
49  * // It will require modifications to work:
50  * // - It may require correct/in-range values for request initialization.
51  * // - It may require specifying regional endpoints when creating the service client as shown in
52  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
53  * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
54  *   FulfillmentName name = FulfillmentName.ofProjectName("[PROJECT]");
55  *   Fulfillment response = fulfillmentsClient.getFulfillment(name);
56  * }
57  * }</pre>
58  *
59  * <p>Note: close() needs to be called on the FulfillmentsClient object to clean up resources such
60  * as threads. In the example above, try-with-resources is used, which automatically calls close().
61  *
62  * <p>The surface of this class includes several types of Java methods for each of the API's
63  * methods:
64  *
65  * <ol>
66  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
67  *       converted into function parameters. It may be the case that not all fields are available as
68  *       parameters, and not every API method will have a flattened method entry point.
69  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
70  *       which must be constructed before the call. Not every API method will have a request object
71  *       method.
72  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
73  *       callable object, which can be used to initiate calls to the service.
74  * </ol>
75  *
76  * <p>See the individual methods for example code.
77  *
78  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
79  * these names, this class includes a format method for each type of name, and additionally a parse
80  * method to extract the individual identifiers contained within names that are returned.
81  *
82  * <p>This class can be customized by passing in a custom instance of FulfillmentsSettings to
83  * create(). For example:
84  *
85  * <p>To customize credentials:
86  *
87  * <pre>{@code
88  * // This snippet has been automatically generated and should be regarded as a code template only.
89  * // It will require modifications to work:
90  * // - It may require correct/in-range values for request initialization.
91  * // - It may require specifying regional endpoints when creating the service client as shown in
92  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
93  * FulfillmentsSettings fulfillmentsSettings =
94  *     FulfillmentsSettings.newBuilder()
95  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
96  *         .build();
97  * FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings);
98  * }</pre>
99  *
100  * <p>To customize the endpoint:
101  *
102  * <pre>{@code
103  * // This snippet has been automatically generated and should be regarded as a code template only.
104  * // It will require modifications to work:
105  * // - It may require correct/in-range values for request initialization.
106  * // - It may require specifying regional endpoints when creating the service client as shown in
107  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
108  * FulfillmentsSettings fulfillmentsSettings =
109  *     FulfillmentsSettings.newBuilder().setEndpoint(myEndpoint).build();
110  * FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings);
111  * }</pre>
112  *
113  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
114  * the wire:
115  *
116  * <pre>{@code
117  * // This snippet has been automatically generated and should be regarded as a code template only.
118  * // It will require modifications to work:
119  * // - It may require correct/in-range values for request initialization.
120  * // - It may require specifying regional endpoints when creating the service client as shown in
121  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
122  * FulfillmentsSettings fulfillmentsSettings = FulfillmentsSettings.newHttpJsonBuilder().build();
123  * FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings);
124  * }</pre>
125  *
126  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
127  */
128 @Generated("by gapic-generator-java")
129 public class FulfillmentsClient implements BackgroundResource {
130   private final FulfillmentsSettings settings;
131   private final FulfillmentsStub stub;
132 
133   /** Constructs an instance of FulfillmentsClient with default settings. */
create()134   public static final FulfillmentsClient create() throws IOException {
135     return create(FulfillmentsSettings.newBuilder().build());
136   }
137 
138   /**
139    * Constructs an instance of FulfillmentsClient, using the given settings. The channels are
140    * created based on the settings passed in, or defaults for any settings that are not set.
141    */
create(FulfillmentsSettings settings)142   public static final FulfillmentsClient create(FulfillmentsSettings settings) throws IOException {
143     return new FulfillmentsClient(settings);
144   }
145 
146   /**
147    * Constructs an instance of FulfillmentsClient, using the given stub for making calls. This is
148    * for advanced usage - prefer using create(FulfillmentsSettings).
149    */
create(FulfillmentsStub stub)150   public static final FulfillmentsClient create(FulfillmentsStub stub) {
151     return new FulfillmentsClient(stub);
152   }
153 
154   /**
155    * Constructs an instance of FulfillmentsClient, using the given settings. This is protected so
156    * that it is easy to make a subclass, but otherwise, the static factory methods should be
157    * preferred.
158    */
FulfillmentsClient(FulfillmentsSettings settings)159   protected FulfillmentsClient(FulfillmentsSettings settings) throws IOException {
160     this.settings = settings;
161     this.stub = ((FulfillmentsStubSettings) settings.getStubSettings()).createStub();
162   }
163 
FulfillmentsClient(FulfillmentsStub stub)164   protected FulfillmentsClient(FulfillmentsStub stub) {
165     this.settings = null;
166     this.stub = stub;
167   }
168 
getSettings()169   public final FulfillmentsSettings getSettings() {
170     return settings;
171   }
172 
getStub()173   public FulfillmentsStub getStub() {
174     return stub;
175   }
176 
177   // AUTO-GENERATED DOCUMENTATION AND METHOD.
178   /**
179    * Retrieves the fulfillment.
180    *
181    * <p>Sample code:
182    *
183    * <pre>{@code
184    * // This snippet has been automatically generated and should be regarded as a code template only.
185    * // It will require modifications to work:
186    * // - It may require correct/in-range values for request initialization.
187    * // - It may require specifying regional endpoints when creating the service client as shown in
188    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
189    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
190    *   FulfillmentName name = FulfillmentName.ofProjectName("[PROJECT]");
191    *   Fulfillment response = fulfillmentsClient.getFulfillment(name);
192    * }
193    * }</pre>
194    *
195    * @param name Required. The name of the fulfillment. Format: `projects/&lt;Project
196    *     ID&gt;/agent/fulfillment`.
197    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
198    */
getFulfillment(FulfillmentName name)199   public final Fulfillment getFulfillment(FulfillmentName name) {
200     GetFulfillmentRequest request =
201         GetFulfillmentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
202     return getFulfillment(request);
203   }
204 
205   // AUTO-GENERATED DOCUMENTATION AND METHOD.
206   /**
207    * Retrieves the fulfillment.
208    *
209    * <p>Sample code:
210    *
211    * <pre>{@code
212    * // This snippet has been automatically generated and should be regarded as a code template only.
213    * // It will require modifications to work:
214    * // - It may require correct/in-range values for request initialization.
215    * // - It may require specifying regional endpoints when creating the service client as shown in
216    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
217    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
218    *   String name = FulfillmentName.ofProjectName("[PROJECT]").toString();
219    *   Fulfillment response = fulfillmentsClient.getFulfillment(name);
220    * }
221    * }</pre>
222    *
223    * @param name Required. The name of the fulfillment. Format: `projects/&lt;Project
224    *     ID&gt;/agent/fulfillment`.
225    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
226    */
getFulfillment(String name)227   public final Fulfillment getFulfillment(String name) {
228     GetFulfillmentRequest request = GetFulfillmentRequest.newBuilder().setName(name).build();
229     return getFulfillment(request);
230   }
231 
232   // AUTO-GENERATED DOCUMENTATION AND METHOD.
233   /**
234    * Retrieves the fulfillment.
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 (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
245    *   GetFulfillmentRequest request =
246    *       GetFulfillmentRequest.newBuilder()
247    *           .setName(FulfillmentName.ofProjectName("[PROJECT]").toString())
248    *           .build();
249    *   Fulfillment response = fulfillmentsClient.getFulfillment(request);
250    * }
251    * }</pre>
252    *
253    * @param request The request object containing all of the parameters for the API call.
254    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
255    */
getFulfillment(GetFulfillmentRequest request)256   public final Fulfillment getFulfillment(GetFulfillmentRequest request) {
257     return getFulfillmentCallable().call(request);
258   }
259 
260   // AUTO-GENERATED DOCUMENTATION AND METHOD.
261   /**
262    * Retrieves the fulfillment.
263    *
264    * <p>Sample code:
265    *
266    * <pre>{@code
267    * // This snippet has been automatically generated and should be regarded as a code template only.
268    * // It will require modifications to work:
269    * // - It may require correct/in-range values for request initialization.
270    * // - It may require specifying regional endpoints when creating the service client as shown in
271    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
272    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
273    *   GetFulfillmentRequest request =
274    *       GetFulfillmentRequest.newBuilder()
275    *           .setName(FulfillmentName.ofProjectName("[PROJECT]").toString())
276    *           .build();
277    *   ApiFuture<Fulfillment> future =
278    *       fulfillmentsClient.getFulfillmentCallable().futureCall(request);
279    *   // Do something.
280    *   Fulfillment response = future.get();
281    * }
282    * }</pre>
283    */
getFulfillmentCallable()284   public final UnaryCallable<GetFulfillmentRequest, Fulfillment> getFulfillmentCallable() {
285     return stub.getFulfillmentCallable();
286   }
287 
288   // AUTO-GENERATED DOCUMENTATION AND METHOD.
289   /**
290    * Updates the fulfillment.
291    *
292    * <p>Sample code:
293    *
294    * <pre>{@code
295    * // This snippet has been automatically generated and should be regarded as a code template only.
296    * // It will require modifications to work:
297    * // - It may require correct/in-range values for request initialization.
298    * // - It may require specifying regional endpoints when creating the service client as shown in
299    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
300    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
301    *   Fulfillment fulfillment = Fulfillment.newBuilder().build();
302    *   FieldMask updateMask = FieldMask.newBuilder().build();
303    *   Fulfillment response = fulfillmentsClient.updateFulfillment(fulfillment, updateMask);
304    * }
305    * }</pre>
306    *
307    * @param fulfillment Required. The fulfillment to update.
308    * @param updateMask Required. The mask to control which fields get updated. If the mask is not
309    *     present, all fields will be updated.
310    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
311    */
updateFulfillment(Fulfillment fulfillment, FieldMask updateMask)312   public final Fulfillment updateFulfillment(Fulfillment fulfillment, FieldMask updateMask) {
313     UpdateFulfillmentRequest request =
314         UpdateFulfillmentRequest.newBuilder()
315             .setFulfillment(fulfillment)
316             .setUpdateMask(updateMask)
317             .build();
318     return updateFulfillment(request);
319   }
320 
321   // AUTO-GENERATED DOCUMENTATION AND METHOD.
322   /**
323    * Updates the fulfillment.
324    *
325    * <p>Sample code:
326    *
327    * <pre>{@code
328    * // This snippet has been automatically generated and should be regarded as a code template only.
329    * // It will require modifications to work:
330    * // - It may require correct/in-range values for request initialization.
331    * // - It may require specifying regional endpoints when creating the service client as shown in
332    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
333    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
334    *   UpdateFulfillmentRequest request =
335    *       UpdateFulfillmentRequest.newBuilder()
336    *           .setFulfillment(Fulfillment.newBuilder().build())
337    *           .setUpdateMask(FieldMask.newBuilder().build())
338    *           .build();
339    *   Fulfillment response = fulfillmentsClient.updateFulfillment(request);
340    * }
341    * }</pre>
342    *
343    * @param request The request object containing all of the parameters for the API call.
344    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
345    */
updateFulfillment(UpdateFulfillmentRequest request)346   public final Fulfillment updateFulfillment(UpdateFulfillmentRequest request) {
347     return updateFulfillmentCallable().call(request);
348   }
349 
350   // AUTO-GENERATED DOCUMENTATION AND METHOD.
351   /**
352    * Updates the fulfillment.
353    *
354    * <p>Sample code:
355    *
356    * <pre>{@code
357    * // This snippet has been automatically generated and should be regarded as a code template only.
358    * // It will require modifications to work:
359    * // - It may require correct/in-range values for request initialization.
360    * // - It may require specifying regional endpoints when creating the service client as shown in
361    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
362    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
363    *   UpdateFulfillmentRequest request =
364    *       UpdateFulfillmentRequest.newBuilder()
365    *           .setFulfillment(Fulfillment.newBuilder().build())
366    *           .setUpdateMask(FieldMask.newBuilder().build())
367    *           .build();
368    *   ApiFuture<Fulfillment> future =
369    *       fulfillmentsClient.updateFulfillmentCallable().futureCall(request);
370    *   // Do something.
371    *   Fulfillment response = future.get();
372    * }
373    * }</pre>
374    */
updateFulfillmentCallable()375   public final UnaryCallable<UpdateFulfillmentRequest, Fulfillment> updateFulfillmentCallable() {
376     return stub.updateFulfillmentCallable();
377   }
378 
379   // AUTO-GENERATED DOCUMENTATION AND METHOD.
380   /**
381    * Lists information about the supported locations for this service.
382    *
383    * <p>Sample code:
384    *
385    * <pre>{@code
386    * // This snippet has been automatically generated and should be regarded as a code template only.
387    * // It will require modifications to work:
388    * // - It may require correct/in-range values for request initialization.
389    * // - It may require specifying regional endpoints when creating the service client as shown in
390    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
391    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
392    *   ListLocationsRequest request =
393    *       ListLocationsRequest.newBuilder()
394    *           .setName("name3373707")
395    *           .setFilter("filter-1274492040")
396    *           .setPageSize(883849137)
397    *           .setPageToken("pageToken873572522")
398    *           .build();
399    *   for (Location element : fulfillmentsClient.listLocations(request).iterateAll()) {
400    *     // doThingsWith(element);
401    *   }
402    * }
403    * }</pre>
404    *
405    * @param request The request object containing all of the parameters for the API call.
406    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
407    */
listLocations(ListLocationsRequest request)408   public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
409     return listLocationsPagedCallable().call(request);
410   }
411 
412   // AUTO-GENERATED DOCUMENTATION AND METHOD.
413   /**
414    * Lists information about the supported locations for this service.
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 (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
425    *   ListLocationsRequest request =
426    *       ListLocationsRequest.newBuilder()
427    *           .setName("name3373707")
428    *           .setFilter("filter-1274492040")
429    *           .setPageSize(883849137)
430    *           .setPageToken("pageToken873572522")
431    *           .build();
432    *   ApiFuture<Location> future =
433    *       fulfillmentsClient.listLocationsPagedCallable().futureCall(request);
434    *   // Do something.
435    *   for (Location element : future.get().iterateAll()) {
436    *     // doThingsWith(element);
437    *   }
438    * }
439    * }</pre>
440    */
441   public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()442       listLocationsPagedCallable() {
443     return stub.listLocationsPagedCallable();
444   }
445 
446   // AUTO-GENERATED DOCUMENTATION AND METHOD.
447   /**
448    * Lists information about the supported locations for this service.
449    *
450    * <p>Sample code:
451    *
452    * <pre>{@code
453    * // This snippet has been automatically generated and should be regarded as a code template only.
454    * // It will require modifications to work:
455    * // - It may require correct/in-range values for request initialization.
456    * // - It may require specifying regional endpoints when creating the service client as shown in
457    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
458    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
459    *   ListLocationsRequest request =
460    *       ListLocationsRequest.newBuilder()
461    *           .setName("name3373707")
462    *           .setFilter("filter-1274492040")
463    *           .setPageSize(883849137)
464    *           .setPageToken("pageToken873572522")
465    *           .build();
466    *   while (true) {
467    *     ListLocationsResponse response = fulfillmentsClient.listLocationsCallable().call(request);
468    *     for (Location element : response.getLocationsList()) {
469    *       // doThingsWith(element);
470    *     }
471    *     String nextPageToken = response.getNextPageToken();
472    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
473    *       request = request.toBuilder().setPageToken(nextPageToken).build();
474    *     } else {
475    *       break;
476    *     }
477    *   }
478    * }
479    * }</pre>
480    */
listLocationsCallable()481   public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
482     return stub.listLocationsCallable();
483   }
484 
485   // AUTO-GENERATED DOCUMENTATION AND METHOD.
486   /**
487    * Gets information about a location.
488    *
489    * <p>Sample code:
490    *
491    * <pre>{@code
492    * // This snippet has been automatically generated and should be regarded as a code template only.
493    * // It will require modifications to work:
494    * // - It may require correct/in-range values for request initialization.
495    * // - It may require specifying regional endpoints when creating the service client as shown in
496    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
497    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
498    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
499    *   Location response = fulfillmentsClient.getLocation(request);
500    * }
501    * }</pre>
502    *
503    * @param request The request object containing all of the parameters for the API call.
504    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
505    */
getLocation(GetLocationRequest request)506   public final Location getLocation(GetLocationRequest request) {
507     return getLocationCallable().call(request);
508   }
509 
510   // AUTO-GENERATED DOCUMENTATION AND METHOD.
511   /**
512    * Gets information about a location.
513    *
514    * <p>Sample code:
515    *
516    * <pre>{@code
517    * // This snippet has been automatically generated and should be regarded as a code template only.
518    * // It will require modifications to work:
519    * // - It may require correct/in-range values for request initialization.
520    * // - It may require specifying regional endpoints when creating the service client as shown in
521    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
522    * try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) {
523    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
524    *   ApiFuture<Location> future = fulfillmentsClient.getLocationCallable().futureCall(request);
525    *   // Do something.
526    *   Location response = future.get();
527    * }
528    * }</pre>
529    */
getLocationCallable()530   public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
531     return stub.getLocationCallable();
532   }
533 
534   @Override
close()535   public final void close() {
536     stub.close();
537   }
538 
539   @Override
shutdown()540   public void shutdown() {
541     stub.shutdown();
542   }
543 
544   @Override
isShutdown()545   public boolean isShutdown() {
546     return stub.isShutdown();
547   }
548 
549   @Override
isTerminated()550   public boolean isTerminated() {
551     return stub.isTerminated();
552   }
553 
554   @Override
shutdownNow()555   public void shutdownNow() {
556     stub.shutdownNow();
557   }
558 
559   @Override
awaitTermination(long duration, TimeUnit unit)560   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
561     return stub.awaitTermination(duration, unit);
562   }
563 
564   public static class ListLocationsPagedResponse
565       extends AbstractPagedListResponse<
566           ListLocationsRequest,
567           ListLocationsResponse,
568           Location,
569           ListLocationsPage,
570           ListLocationsFixedSizeCollection> {
571 
createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)572     public static ApiFuture<ListLocationsPagedResponse> createAsync(
573         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
574         ApiFuture<ListLocationsResponse> futureResponse) {
575       ApiFuture<ListLocationsPage> futurePage =
576           ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
577       return ApiFutures.transform(
578           futurePage,
579           input -> new ListLocationsPagedResponse(input),
580           MoreExecutors.directExecutor());
581     }
582 
ListLocationsPagedResponse(ListLocationsPage page)583     private ListLocationsPagedResponse(ListLocationsPage page) {
584       super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
585     }
586   }
587 
588   public static class ListLocationsPage
589       extends AbstractPage<
590           ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
591 
ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)592     private ListLocationsPage(
593         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
594         ListLocationsResponse response) {
595       super(context, response);
596     }
597 
createEmptyPage()598     private static ListLocationsPage createEmptyPage() {
599       return new ListLocationsPage(null, null);
600     }
601 
602     @Override
createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)603     protected ListLocationsPage createPage(
604         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
605         ListLocationsResponse response) {
606       return new ListLocationsPage(context, response);
607     }
608 
609     @Override
createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)610     public ApiFuture<ListLocationsPage> createPageAsync(
611         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
612         ApiFuture<ListLocationsResponse> futureResponse) {
613       return super.createPageAsync(context, futureResponse);
614     }
615   }
616 
617   public static class ListLocationsFixedSizeCollection
618       extends AbstractFixedSizeCollection<
619           ListLocationsRequest,
620           ListLocationsResponse,
621           Location,
622           ListLocationsPage,
623           ListLocationsFixedSizeCollection> {
624 
ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)625     private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
626       super(pages, collectionSize);
627     }
628 
createEmptyCollection()629     private static ListLocationsFixedSizeCollection createEmptyCollection() {
630       return new ListLocationsFixedSizeCollection(null, 0);
631     }
632 
633     @Override
createCollection( List<ListLocationsPage> pages, int collectionSize)634     protected ListLocationsFixedSizeCollection createCollection(
635         List<ListLocationsPage> pages, int collectionSize) {
636       return new ListLocationsFixedSizeCollection(pages, collectionSize);
637     }
638   }
639 }
640