• 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.ConversationsStub;
28 import com.google.cloud.dialogflow.v2.stub.ConversationsStubSettings;
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 java.io.IOException;
35 import java.util.List;
36 import java.util.concurrent.TimeUnit;
37 import javax.annotation.Generated;
38 
39 // AUTO-GENERATED DOCUMENTATION AND CLASS.
40 /**
41  * Service Description: Service for managing
42  * [Conversations][google.cloud.dialogflow.v2.Conversation].
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
54  *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
55  *   Conversation conversation = Conversation.newBuilder().build();
56  *   Conversation response = conversationsClient.createConversation(parent, conversation);
57  * }
58  * }</pre>
59  *
60  * <p>Note: close() needs to be called on the ConversationsClient object to clean up resources such
61  * as threads. In the example above, try-with-resources is used, which automatically calls close().
62  *
63  * <p>The surface of this class includes several types of Java methods for each of the API's
64  * methods:
65  *
66  * <ol>
67  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
68  *       converted into function parameters. It may be the case that not all fields are available as
69  *       parameters, and not every API method will have a flattened method entry point.
70  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
71  *       which must be constructed before the call. Not every API method will have a request object
72  *       method.
73  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
74  *       callable object, which can be used to initiate calls to the service.
75  * </ol>
76  *
77  * <p>See the individual methods for example code.
78  *
79  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
80  * these names, this class includes a format method for each type of name, and additionally a parse
81  * method to extract the individual identifiers contained within names that are returned.
82  *
83  * <p>This class can be customized by passing in a custom instance of ConversationsSettings to
84  * create(). For example:
85  *
86  * <p>To customize credentials:
87  *
88  * <pre>{@code
89  * // This snippet has been automatically generated and should be regarded as a code template only.
90  * // It will require modifications to work:
91  * // - It may require correct/in-range values for request initialization.
92  * // - It may require specifying regional endpoints when creating the service client as shown in
93  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
94  * ConversationsSettings conversationsSettings =
95  *     ConversationsSettings.newBuilder()
96  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
97  *         .build();
98  * ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
99  * }</pre>
100  *
101  * <p>To customize the endpoint:
102  *
103  * <pre>{@code
104  * // This snippet has been automatically generated and should be regarded as a code template only.
105  * // It will require modifications to work:
106  * // - It may require correct/in-range values for request initialization.
107  * // - It may require specifying regional endpoints when creating the service client as shown in
108  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
109  * ConversationsSettings conversationsSettings =
110  *     ConversationsSettings.newBuilder().setEndpoint(myEndpoint).build();
111  * ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
112  * }</pre>
113  *
114  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
115  * the wire:
116  *
117  * <pre>{@code
118  * // This snippet has been automatically generated and should be regarded as a code template only.
119  * // It will require modifications to work:
120  * // - It may require correct/in-range values for request initialization.
121  * // - It may require specifying regional endpoints when creating the service client as shown in
122  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
123  * ConversationsSettings conversationsSettings =
124  *     ConversationsSettings.newHttpJsonBuilder().build();
125  * ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
126  * }</pre>
127  *
128  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
129  */
130 @Generated("by gapic-generator-java")
131 public class ConversationsClient implements BackgroundResource {
132   private final ConversationsSettings settings;
133   private final ConversationsStub stub;
134 
135   /** Constructs an instance of ConversationsClient with default settings. */
create()136   public static final ConversationsClient create() throws IOException {
137     return create(ConversationsSettings.newBuilder().build());
138   }
139 
140   /**
141    * Constructs an instance of ConversationsClient, using the given settings. The channels are
142    * created based on the settings passed in, or defaults for any settings that are not set.
143    */
create(ConversationsSettings settings)144   public static final ConversationsClient create(ConversationsSettings settings)
145       throws IOException {
146     return new ConversationsClient(settings);
147   }
148 
149   /**
150    * Constructs an instance of ConversationsClient, using the given stub for making calls. This is
151    * for advanced usage - prefer using create(ConversationsSettings).
152    */
create(ConversationsStub stub)153   public static final ConversationsClient create(ConversationsStub stub) {
154     return new ConversationsClient(stub);
155   }
156 
157   /**
158    * Constructs an instance of ConversationsClient, using the given settings. This is protected so
159    * that it is easy to make a subclass, but otherwise, the static factory methods should be
160    * preferred.
161    */
ConversationsClient(ConversationsSettings settings)162   protected ConversationsClient(ConversationsSettings settings) throws IOException {
163     this.settings = settings;
164     this.stub = ((ConversationsStubSettings) settings.getStubSettings()).createStub();
165   }
166 
ConversationsClient(ConversationsStub stub)167   protected ConversationsClient(ConversationsStub stub) {
168     this.settings = null;
169     this.stub = stub;
170   }
171 
getSettings()172   public final ConversationsSettings getSettings() {
173     return settings;
174   }
175 
getStub()176   public ConversationsStub getStub() {
177     return stub;
178   }
179 
180   // AUTO-GENERATED DOCUMENTATION AND METHOD.
181   /**
182    * Creates a new conversation. Conversations are auto-completed after 24 hours.
183    *
184    * <p>Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage
185    * and Assist Stage.
186    *
187    * <p>For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
188    *
189    * <p>For Assist Stage, there's no dialogflow agent responding to user queries. But we will
190    * provide suggestions which are generated from conversation.
191    *
192    * <p>If
193    * [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile]
194    * is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`,
195    * otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an
196    * [Intent][google.cloud.dialogflow.v2.Intent] with
197    * [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered,
198    * conversation will transfer to Assist Stage.
199    *
200    * <p>Sample code:
201    *
202    * <pre>{@code
203    * // This snippet has been automatically generated and should be regarded as a code template only.
204    * // It will require modifications to work:
205    * // - It may require correct/in-range values for request initialization.
206    * // - It may require specifying regional endpoints when creating the service client as shown in
207    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
208    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
209    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
210    *   Conversation conversation = Conversation.newBuilder().build();
211    *   Conversation response = conversationsClient.createConversation(parent, conversation);
212    * }
213    * }</pre>
214    *
215    * @param parent Required. Resource identifier of the project creating the conversation. Format:
216    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;`.
217    * @param conversation Required. The conversation to create.
218    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
219    */
createConversation(LocationName parent, Conversation conversation)220   public final Conversation createConversation(LocationName parent, Conversation conversation) {
221     CreateConversationRequest request =
222         CreateConversationRequest.newBuilder()
223             .setParent(parent == null ? null : parent.toString())
224             .setConversation(conversation)
225             .build();
226     return createConversation(request);
227   }
228 
229   // AUTO-GENERATED DOCUMENTATION AND METHOD.
230   /**
231    * Creates a new conversation. Conversations are auto-completed after 24 hours.
232    *
233    * <p>Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage
234    * and Assist Stage.
235    *
236    * <p>For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
237    *
238    * <p>For Assist Stage, there's no dialogflow agent responding to user queries. But we will
239    * provide suggestions which are generated from conversation.
240    *
241    * <p>If
242    * [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile]
243    * is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`,
244    * otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an
245    * [Intent][google.cloud.dialogflow.v2.Intent] with
246    * [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered,
247    * conversation will transfer to Assist Stage.
248    *
249    * <p>Sample code:
250    *
251    * <pre>{@code
252    * // This snippet has been automatically generated and should be regarded as a code template only.
253    * // It will require modifications to work:
254    * // - It may require correct/in-range values for request initialization.
255    * // - It may require specifying regional endpoints when creating the service client as shown in
256    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
257    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
258    *   ProjectName parent = ProjectName.of("[PROJECT]");
259    *   Conversation conversation = Conversation.newBuilder().build();
260    *   Conversation response = conversationsClient.createConversation(parent, conversation);
261    * }
262    * }</pre>
263    *
264    * @param parent Required. Resource identifier of the project creating the conversation. Format:
265    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;`.
266    * @param conversation Required. The conversation to create.
267    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
268    */
createConversation(ProjectName parent, Conversation conversation)269   public final Conversation createConversation(ProjectName parent, Conversation conversation) {
270     CreateConversationRequest request =
271         CreateConversationRequest.newBuilder()
272             .setParent(parent == null ? null : parent.toString())
273             .setConversation(conversation)
274             .build();
275     return createConversation(request);
276   }
277 
278   // AUTO-GENERATED DOCUMENTATION AND METHOD.
279   /**
280    * Creates a new conversation. Conversations are auto-completed after 24 hours.
281    *
282    * <p>Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage
283    * and Assist Stage.
284    *
285    * <p>For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
286    *
287    * <p>For Assist Stage, there's no dialogflow agent responding to user queries. But we will
288    * provide suggestions which are generated from conversation.
289    *
290    * <p>If
291    * [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile]
292    * is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`,
293    * otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an
294    * [Intent][google.cloud.dialogflow.v2.Intent] with
295    * [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered,
296    * conversation will transfer to Assist Stage.
297    *
298    * <p>Sample code:
299    *
300    * <pre>{@code
301    * // This snippet has been automatically generated and should be regarded as a code template only.
302    * // It will require modifications to work:
303    * // - It may require correct/in-range values for request initialization.
304    * // - It may require specifying regional endpoints when creating the service client as shown in
305    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
306    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
307    *   String parent = ProjectName.of("[PROJECT]").toString();
308    *   Conversation conversation = Conversation.newBuilder().build();
309    *   Conversation response = conversationsClient.createConversation(parent, conversation);
310    * }
311    * }</pre>
312    *
313    * @param parent Required. Resource identifier of the project creating the conversation. Format:
314    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;`.
315    * @param conversation Required. The conversation to create.
316    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
317    */
createConversation(String parent, Conversation conversation)318   public final Conversation createConversation(String parent, Conversation conversation) {
319     CreateConversationRequest request =
320         CreateConversationRequest.newBuilder()
321             .setParent(parent)
322             .setConversation(conversation)
323             .build();
324     return createConversation(request);
325   }
326 
327   // AUTO-GENERATED DOCUMENTATION AND METHOD.
328   /**
329    * Creates a new conversation. Conversations are auto-completed after 24 hours.
330    *
331    * <p>Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage
332    * and Assist Stage.
333    *
334    * <p>For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
335    *
336    * <p>For Assist Stage, there's no dialogflow agent responding to user queries. But we will
337    * provide suggestions which are generated from conversation.
338    *
339    * <p>If
340    * [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile]
341    * is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`,
342    * otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an
343    * [Intent][google.cloud.dialogflow.v2.Intent] with
344    * [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered,
345    * conversation will transfer to Assist Stage.
346    *
347    * <p>Sample code:
348    *
349    * <pre>{@code
350    * // This snippet has been automatically generated and should be regarded as a code template only.
351    * // It will require modifications to work:
352    * // - It may require correct/in-range values for request initialization.
353    * // - It may require specifying regional endpoints when creating the service client as shown in
354    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
355    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
356    *   CreateConversationRequest request =
357    *       CreateConversationRequest.newBuilder()
358    *           .setParent(ProjectName.of("[PROJECT]").toString())
359    *           .setConversation(Conversation.newBuilder().build())
360    *           .setConversationId("conversationId-1676095234")
361    *           .build();
362    *   Conversation response = conversationsClient.createConversation(request);
363    * }
364    * }</pre>
365    *
366    * @param request The request object containing all of the parameters for the API call.
367    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
368    */
createConversation(CreateConversationRequest request)369   public final Conversation createConversation(CreateConversationRequest request) {
370     return createConversationCallable().call(request);
371   }
372 
373   // AUTO-GENERATED DOCUMENTATION AND METHOD.
374   /**
375    * Creates a new conversation. Conversations are auto-completed after 24 hours.
376    *
377    * <p>Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage
378    * and Assist Stage.
379    *
380    * <p>For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
381    *
382    * <p>For Assist Stage, there's no dialogflow agent responding to user queries. But we will
383    * provide suggestions which are generated from conversation.
384    *
385    * <p>If
386    * [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile]
387    * is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`,
388    * otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an
389    * [Intent][google.cloud.dialogflow.v2.Intent] with
390    * [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered,
391    * conversation will transfer to Assist Stage.
392    *
393    * <p>Sample code:
394    *
395    * <pre>{@code
396    * // This snippet has been automatically generated and should be regarded as a code template only.
397    * // It will require modifications to work:
398    * // - It may require correct/in-range values for request initialization.
399    * // - It may require specifying regional endpoints when creating the service client as shown in
400    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
401    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
402    *   CreateConversationRequest request =
403    *       CreateConversationRequest.newBuilder()
404    *           .setParent(ProjectName.of("[PROJECT]").toString())
405    *           .setConversation(Conversation.newBuilder().build())
406    *           .setConversationId("conversationId-1676095234")
407    *           .build();
408    *   ApiFuture<Conversation> future =
409    *       conversationsClient.createConversationCallable().futureCall(request);
410    *   // Do something.
411    *   Conversation response = future.get();
412    * }
413    * }</pre>
414    */
createConversationCallable()415   public final UnaryCallable<CreateConversationRequest, Conversation> createConversationCallable() {
416     return stub.createConversationCallable();
417   }
418 
419   // AUTO-GENERATED DOCUMENTATION AND METHOD.
420   /**
421    * Returns the list of all conversations in the specified project.
422    *
423    * <p>Sample code:
424    *
425    * <pre>{@code
426    * // This snippet has been automatically generated and should be regarded as a code template only.
427    * // It will require modifications to work:
428    * // - It may require correct/in-range values for request initialization.
429    * // - It may require specifying regional endpoints when creating the service client as shown in
430    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
431    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
432    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
433    *   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
434    *     // doThingsWith(element);
435    *   }
436    * }
437    * }</pre>
438    *
439    * @param parent Required. The project from which to list all conversation. Format:
440    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;`.
441    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
442    */
listConversations(LocationName parent)443   public final ListConversationsPagedResponse listConversations(LocationName parent) {
444     ListConversationsRequest request =
445         ListConversationsRequest.newBuilder()
446             .setParent(parent == null ? null : parent.toString())
447             .build();
448     return listConversations(request);
449   }
450 
451   // AUTO-GENERATED DOCUMENTATION AND METHOD.
452   /**
453    * Returns the list of all conversations in the specified project.
454    *
455    * <p>Sample code:
456    *
457    * <pre>{@code
458    * // This snippet has been automatically generated and should be regarded as a code template only.
459    * // It will require modifications to work:
460    * // - It may require correct/in-range values for request initialization.
461    * // - It may require specifying regional endpoints when creating the service client as shown in
462    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
463    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
464    *   ProjectName parent = ProjectName.of("[PROJECT]");
465    *   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
466    *     // doThingsWith(element);
467    *   }
468    * }
469    * }</pre>
470    *
471    * @param parent Required. The project from which to list all conversation. Format:
472    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;`.
473    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
474    */
listConversations(ProjectName parent)475   public final ListConversationsPagedResponse listConversations(ProjectName parent) {
476     ListConversationsRequest request =
477         ListConversationsRequest.newBuilder()
478             .setParent(parent == null ? null : parent.toString())
479             .build();
480     return listConversations(request);
481   }
482 
483   // AUTO-GENERATED DOCUMENTATION AND METHOD.
484   /**
485    * Returns the list of all conversations in the specified project.
486    *
487    * <p>Sample code:
488    *
489    * <pre>{@code
490    * // This snippet has been automatically generated and should be regarded as a code template only.
491    * // It will require modifications to work:
492    * // - It may require correct/in-range values for request initialization.
493    * // - It may require specifying regional endpoints when creating the service client as shown in
494    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
495    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
496    *   String parent = ProjectName.of("[PROJECT]").toString();
497    *   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
498    *     // doThingsWith(element);
499    *   }
500    * }
501    * }</pre>
502    *
503    * @param parent Required. The project from which to list all conversation. Format:
504    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;`.
505    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
506    */
listConversations(String parent)507   public final ListConversationsPagedResponse listConversations(String parent) {
508     ListConversationsRequest request =
509         ListConversationsRequest.newBuilder().setParent(parent).build();
510     return listConversations(request);
511   }
512 
513   // AUTO-GENERATED DOCUMENTATION AND METHOD.
514   /**
515    * Returns the list of all conversations in the specified project.
516    *
517    * <p>Sample code:
518    *
519    * <pre>{@code
520    * // This snippet has been automatically generated and should be regarded as a code template only.
521    * // It will require modifications to work:
522    * // - It may require correct/in-range values for request initialization.
523    * // - It may require specifying regional endpoints when creating the service client as shown in
524    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
525    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
526    *   ListConversationsRequest request =
527    *       ListConversationsRequest.newBuilder()
528    *           .setParent(ProjectName.of("[PROJECT]").toString())
529    *           .setPageSize(883849137)
530    *           .setPageToken("pageToken873572522")
531    *           .setFilter("filter-1274492040")
532    *           .build();
533    *   for (Conversation element : conversationsClient.listConversations(request).iterateAll()) {
534    *     // doThingsWith(element);
535    *   }
536    * }
537    * }</pre>
538    *
539    * @param request The request object containing all of the parameters for the API call.
540    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
541    */
listConversations(ListConversationsRequest request)542   public final ListConversationsPagedResponse listConversations(ListConversationsRequest request) {
543     return listConversationsPagedCallable().call(request);
544   }
545 
546   // AUTO-GENERATED DOCUMENTATION AND METHOD.
547   /**
548    * Returns the list of all conversations in the specified 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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
559    *   ListConversationsRequest request =
560    *       ListConversationsRequest.newBuilder()
561    *           .setParent(ProjectName.of("[PROJECT]").toString())
562    *           .setPageSize(883849137)
563    *           .setPageToken("pageToken873572522")
564    *           .setFilter("filter-1274492040")
565    *           .build();
566    *   ApiFuture<Conversation> future =
567    *       conversationsClient.listConversationsPagedCallable().futureCall(request);
568    *   // Do something.
569    *   for (Conversation element : future.get().iterateAll()) {
570    *     // doThingsWith(element);
571    *   }
572    * }
573    * }</pre>
574    */
575   public final UnaryCallable<ListConversationsRequest, ListConversationsPagedResponse>
listConversationsPagedCallable()576       listConversationsPagedCallable() {
577     return stub.listConversationsPagedCallable();
578   }
579 
580   // AUTO-GENERATED DOCUMENTATION AND METHOD.
581   /**
582    * Returns the list of all conversations in the specified 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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
593    *   ListConversationsRequest request =
594    *       ListConversationsRequest.newBuilder()
595    *           .setParent(ProjectName.of("[PROJECT]").toString())
596    *           .setPageSize(883849137)
597    *           .setPageToken("pageToken873572522")
598    *           .setFilter("filter-1274492040")
599    *           .build();
600    *   while (true) {
601    *     ListConversationsResponse response =
602    *         conversationsClient.listConversationsCallable().call(request);
603    *     for (Conversation element : response.getConversationsList()) {
604    *       // doThingsWith(element);
605    *     }
606    *     String nextPageToken = response.getNextPageToken();
607    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
608    *       request = request.toBuilder().setPageToken(nextPageToken).build();
609    *     } else {
610    *       break;
611    *     }
612    *   }
613    * }
614    * }</pre>
615    */
616   public final UnaryCallable<ListConversationsRequest, ListConversationsResponse>
listConversationsCallable()617       listConversationsCallable() {
618     return stub.listConversationsCallable();
619   }
620 
621   // AUTO-GENERATED DOCUMENTATION AND METHOD.
622   /**
623    * Retrieves the specific conversation.
624    *
625    * <p>Sample code:
626    *
627    * <pre>{@code
628    * // This snippet has been automatically generated and should be regarded as a code template only.
629    * // It will require modifications to work:
630    * // - It may require correct/in-range values for request initialization.
631    * // - It may require specifying regional endpoints when creating the service client as shown in
632    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
633    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
634    *   ConversationName name =
635    *       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
636    *   Conversation response = conversationsClient.getConversation(name);
637    * }
638    * }</pre>
639    *
640    * @param name Required. The name of the conversation. Format: `projects/&lt;Project
641    *     ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation ID&gt;`.
642    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
643    */
getConversation(ConversationName name)644   public final Conversation getConversation(ConversationName name) {
645     GetConversationRequest request =
646         GetConversationRequest.newBuilder().setName(name == null ? null : name.toString()).build();
647     return getConversation(request);
648   }
649 
650   // AUTO-GENERATED DOCUMENTATION AND METHOD.
651   /**
652    * Retrieves the specific conversation.
653    *
654    * <p>Sample code:
655    *
656    * <pre>{@code
657    * // This snippet has been automatically generated and should be regarded as a code template only.
658    * // It will require modifications to work:
659    * // - It may require correct/in-range values for request initialization.
660    * // - It may require specifying regional endpoints when creating the service client as shown in
661    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
662    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
663    *   String name =
664    *       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
665    *   Conversation response = conversationsClient.getConversation(name);
666    * }
667    * }</pre>
668    *
669    * @param name Required. The name of the conversation. Format: `projects/&lt;Project
670    *     ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation ID&gt;`.
671    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
672    */
getConversation(String name)673   public final Conversation getConversation(String name) {
674     GetConversationRequest request = GetConversationRequest.newBuilder().setName(name).build();
675     return getConversation(request);
676   }
677 
678   // AUTO-GENERATED DOCUMENTATION AND METHOD.
679   /**
680    * Retrieves the specific conversation.
681    *
682    * <p>Sample code:
683    *
684    * <pre>{@code
685    * // This snippet has been automatically generated and should be regarded as a code template only.
686    * // It will require modifications to work:
687    * // - It may require correct/in-range values for request initialization.
688    * // - It may require specifying regional endpoints when creating the service client as shown in
689    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
690    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
691    *   GetConversationRequest request =
692    *       GetConversationRequest.newBuilder()
693    *           .setName(
694    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
695    *                   .toString())
696    *           .build();
697    *   Conversation response = conversationsClient.getConversation(request);
698    * }
699    * }</pre>
700    *
701    * @param request The request object containing all of the parameters for the API call.
702    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
703    */
getConversation(GetConversationRequest request)704   public final Conversation getConversation(GetConversationRequest request) {
705     return getConversationCallable().call(request);
706   }
707 
708   // AUTO-GENERATED DOCUMENTATION AND METHOD.
709   /**
710    * Retrieves the specific conversation.
711    *
712    * <p>Sample code:
713    *
714    * <pre>{@code
715    * // This snippet has been automatically generated and should be regarded as a code template only.
716    * // It will require modifications to work:
717    * // - It may require correct/in-range values for request initialization.
718    * // - It may require specifying regional endpoints when creating the service client as shown in
719    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
720    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
721    *   GetConversationRequest request =
722    *       GetConversationRequest.newBuilder()
723    *           .setName(
724    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
725    *                   .toString())
726    *           .build();
727    *   ApiFuture<Conversation> future =
728    *       conversationsClient.getConversationCallable().futureCall(request);
729    *   // Do something.
730    *   Conversation response = future.get();
731    * }
732    * }</pre>
733    */
getConversationCallable()734   public final UnaryCallable<GetConversationRequest, Conversation> getConversationCallable() {
735     return stub.getConversationCallable();
736   }
737 
738   // AUTO-GENERATED DOCUMENTATION AND METHOD.
739   /**
740    * Completes the specified conversation. Finished conversations are purged from the database after
741    * 30 days.
742    *
743    * <p>Sample code:
744    *
745    * <pre>{@code
746    * // This snippet has been automatically generated and should be regarded as a code template only.
747    * // It will require modifications to work:
748    * // - It may require correct/in-range values for request initialization.
749    * // - It may require specifying regional endpoints when creating the service client as shown in
750    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
751    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
752    *   ConversationName name =
753    *       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
754    *   Conversation response = conversationsClient.completeConversation(name);
755    * }
756    * }</pre>
757    *
758    * @param name Required. Resource identifier of the conversation to close. Format:
759    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation
760    *     ID&gt;`.
761    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
762    */
completeConversation(ConversationName name)763   public final Conversation completeConversation(ConversationName name) {
764     CompleteConversationRequest request =
765         CompleteConversationRequest.newBuilder()
766             .setName(name == null ? null : name.toString())
767             .build();
768     return completeConversation(request);
769   }
770 
771   // AUTO-GENERATED DOCUMENTATION AND METHOD.
772   /**
773    * Completes the specified conversation. Finished conversations are purged from the database after
774    * 30 days.
775    *
776    * <p>Sample code:
777    *
778    * <pre>{@code
779    * // This snippet has been automatically generated and should be regarded as a code template only.
780    * // It will require modifications to work:
781    * // - It may require correct/in-range values for request initialization.
782    * // - It may require specifying regional endpoints when creating the service client as shown in
783    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
784    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
785    *   String name =
786    *       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
787    *   Conversation response = conversationsClient.completeConversation(name);
788    * }
789    * }</pre>
790    *
791    * @param name Required. Resource identifier of the conversation to close. Format:
792    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation
793    *     ID&gt;`.
794    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
795    */
completeConversation(String name)796   public final Conversation completeConversation(String name) {
797     CompleteConversationRequest request =
798         CompleteConversationRequest.newBuilder().setName(name).build();
799     return completeConversation(request);
800   }
801 
802   // AUTO-GENERATED DOCUMENTATION AND METHOD.
803   /**
804    * Completes the specified conversation. Finished conversations are purged from the database after
805    * 30 days.
806    *
807    * <p>Sample code:
808    *
809    * <pre>{@code
810    * // This snippet has been automatically generated and should be regarded as a code template only.
811    * // It will require modifications to work:
812    * // - It may require correct/in-range values for request initialization.
813    * // - It may require specifying regional endpoints when creating the service client as shown in
814    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
815    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
816    *   CompleteConversationRequest request =
817    *       CompleteConversationRequest.newBuilder()
818    *           .setName(
819    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
820    *                   .toString())
821    *           .build();
822    *   Conversation response = conversationsClient.completeConversation(request);
823    * }
824    * }</pre>
825    *
826    * @param request The request object containing all of the parameters for the API call.
827    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
828    */
completeConversation(CompleteConversationRequest request)829   public final Conversation completeConversation(CompleteConversationRequest request) {
830     return completeConversationCallable().call(request);
831   }
832 
833   // AUTO-GENERATED DOCUMENTATION AND METHOD.
834   /**
835    * Completes the specified conversation. Finished conversations are purged from the database after
836    * 30 days.
837    *
838    * <p>Sample code:
839    *
840    * <pre>{@code
841    * // This snippet has been automatically generated and should be regarded as a code template only.
842    * // It will require modifications to work:
843    * // - It may require correct/in-range values for request initialization.
844    * // - It may require specifying regional endpoints when creating the service client as shown in
845    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
846    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
847    *   CompleteConversationRequest request =
848    *       CompleteConversationRequest.newBuilder()
849    *           .setName(
850    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
851    *                   .toString())
852    *           .build();
853    *   ApiFuture<Conversation> future =
854    *       conversationsClient.completeConversationCallable().futureCall(request);
855    *   // Do something.
856    *   Conversation response = future.get();
857    * }
858    * }</pre>
859    */
860   public final UnaryCallable<CompleteConversationRequest, Conversation>
completeConversationCallable()861       completeConversationCallable() {
862     return stub.completeConversationCallable();
863   }
864 
865   // AUTO-GENERATED DOCUMENTATION AND METHOD.
866   /**
867    * Lists messages that belong to a given conversation. `messages` are ordered by `create_time` in
868    * descending order. To fetch updates without duplication, send request with filter
869    * `create_time_epoch_microseconds &gt; [first item's create_time of previous request]` and empty
870    * page_token.
871    *
872    * <p>Sample code:
873    *
874    * <pre>{@code
875    * // This snippet has been automatically generated and should be regarded as a code template only.
876    * // It will require modifications to work:
877    * // - It may require correct/in-range values for request initialization.
878    * // - It may require specifying regional endpoints when creating the service client as shown in
879    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
880    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
881    *   ConversationName parent =
882    *       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
883    *   for (Message element : conversationsClient.listMessages(parent).iterateAll()) {
884    *     // doThingsWith(element);
885    *   }
886    * }
887    * }</pre>
888    *
889    * @param parent Required. The name of the conversation to list messages for. Format:
890    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation
891    *     ID&gt;`
892    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
893    */
listMessages(ConversationName parent)894   public final ListMessagesPagedResponse listMessages(ConversationName parent) {
895     ListMessagesRequest request =
896         ListMessagesRequest.newBuilder()
897             .setParent(parent == null ? null : parent.toString())
898             .build();
899     return listMessages(request);
900   }
901 
902   // AUTO-GENERATED DOCUMENTATION AND METHOD.
903   /**
904    * Lists messages that belong to a given conversation. `messages` are ordered by `create_time` in
905    * descending order. To fetch updates without duplication, send request with filter
906    * `create_time_epoch_microseconds &gt; [first item's create_time of previous request]` and empty
907    * page_token.
908    *
909    * <p>Sample code:
910    *
911    * <pre>{@code
912    * // This snippet has been automatically generated and should be regarded as a code template only.
913    * // It will require modifications to work:
914    * // - It may require correct/in-range values for request initialization.
915    * // - It may require specifying regional endpoints when creating the service client as shown in
916    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
917    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
918    *   String parent =
919    *       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
920    *   for (Message element : conversationsClient.listMessages(parent).iterateAll()) {
921    *     // doThingsWith(element);
922    *   }
923    * }
924    * }</pre>
925    *
926    * @param parent Required. The name of the conversation to list messages for. Format:
927    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation
928    *     ID&gt;`
929    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
930    */
listMessages(String parent)931   public final ListMessagesPagedResponse listMessages(String parent) {
932     ListMessagesRequest request = ListMessagesRequest.newBuilder().setParent(parent).build();
933     return listMessages(request);
934   }
935 
936   // AUTO-GENERATED DOCUMENTATION AND METHOD.
937   /**
938    * Lists messages that belong to a given conversation. `messages` are ordered by `create_time` in
939    * descending order. To fetch updates without duplication, send request with filter
940    * `create_time_epoch_microseconds &gt; [first item's create_time of previous request]` and empty
941    * page_token.
942    *
943    * <p>Sample code:
944    *
945    * <pre>{@code
946    * // This snippet has been automatically generated and should be regarded as a code template only.
947    * // It will require modifications to work:
948    * // - It may require correct/in-range values for request initialization.
949    * // - It may require specifying regional endpoints when creating the service client as shown in
950    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
951    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
952    *   ListMessagesRequest request =
953    *       ListMessagesRequest.newBuilder()
954    *           .setParent(
955    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
956    *                   .toString())
957    *           .setFilter("filter-1274492040")
958    *           .setPageSize(883849137)
959    *           .setPageToken("pageToken873572522")
960    *           .build();
961    *   for (Message element : conversationsClient.listMessages(request).iterateAll()) {
962    *     // doThingsWith(element);
963    *   }
964    * }
965    * }</pre>
966    *
967    * @param request The request object containing all of the parameters for the API call.
968    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
969    */
listMessages(ListMessagesRequest request)970   public final ListMessagesPagedResponse listMessages(ListMessagesRequest request) {
971     return listMessagesPagedCallable().call(request);
972   }
973 
974   // AUTO-GENERATED DOCUMENTATION AND METHOD.
975   /**
976    * Lists messages that belong to a given conversation. `messages` are ordered by `create_time` in
977    * descending order. To fetch updates without duplication, send request with filter
978    * `create_time_epoch_microseconds &gt; [first item's create_time of previous request]` and empty
979    * page_token.
980    *
981    * <p>Sample code:
982    *
983    * <pre>{@code
984    * // This snippet has been automatically generated and should be regarded as a code template only.
985    * // It will require modifications to work:
986    * // - It may require correct/in-range values for request initialization.
987    * // - It may require specifying regional endpoints when creating the service client as shown in
988    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
989    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
990    *   ListMessagesRequest request =
991    *       ListMessagesRequest.newBuilder()
992    *           .setParent(
993    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
994    *                   .toString())
995    *           .setFilter("filter-1274492040")
996    *           .setPageSize(883849137)
997    *           .setPageToken("pageToken873572522")
998    *           .build();
999    *   ApiFuture<Message> future =
1000    *       conversationsClient.listMessagesPagedCallable().futureCall(request);
1001    *   // Do something.
1002    *   for (Message element : future.get().iterateAll()) {
1003    *     // doThingsWith(element);
1004    *   }
1005    * }
1006    * }</pre>
1007    */
1008   public final UnaryCallable<ListMessagesRequest, ListMessagesPagedResponse>
listMessagesPagedCallable()1009       listMessagesPagedCallable() {
1010     return stub.listMessagesPagedCallable();
1011   }
1012 
1013   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1014   /**
1015    * Lists messages that belong to a given conversation. `messages` are ordered by `create_time` in
1016    * descending order. To fetch updates without duplication, send request with filter
1017    * `create_time_epoch_microseconds &gt; [first item's create_time of previous request]` and empty
1018    * page_token.
1019    *
1020    * <p>Sample code:
1021    *
1022    * <pre>{@code
1023    * // This snippet has been automatically generated and should be regarded as a code template only.
1024    * // It will require modifications to work:
1025    * // - It may require correct/in-range values for request initialization.
1026    * // - It may require specifying regional endpoints when creating the service client as shown in
1027    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1028    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1029    *   ListMessagesRequest request =
1030    *       ListMessagesRequest.newBuilder()
1031    *           .setParent(
1032    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
1033    *                   .toString())
1034    *           .setFilter("filter-1274492040")
1035    *           .setPageSize(883849137)
1036    *           .setPageToken("pageToken873572522")
1037    *           .build();
1038    *   while (true) {
1039    *     ListMessagesResponse response = conversationsClient.listMessagesCallable().call(request);
1040    *     for (Message element : response.getMessagesList()) {
1041    *       // doThingsWith(element);
1042    *     }
1043    *     String nextPageToken = response.getNextPageToken();
1044    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
1045    *       request = request.toBuilder().setPageToken(nextPageToken).build();
1046    *     } else {
1047    *       break;
1048    *     }
1049    *   }
1050    * }
1051    * }</pre>
1052    */
listMessagesCallable()1053   public final UnaryCallable<ListMessagesRequest, ListMessagesResponse> listMessagesCallable() {
1054     return stub.listMessagesCallable();
1055   }
1056 
1057   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1058   /**
1059    * Suggests summary for a conversation based on specific historical messages. The range of the
1060    * messages to be used for summary can be specified in the request.
1061    *
1062    * <p>Sample code:
1063    *
1064    * <pre>{@code
1065    * // This snippet has been automatically generated and should be regarded as a code template only.
1066    * // It will require modifications to work:
1067    * // - It may require correct/in-range values for request initialization.
1068    * // - It may require specifying regional endpoints when creating the service client as shown in
1069    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1070    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1071    *   ConversationName conversation =
1072    *       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
1073    *   SuggestConversationSummaryResponse response =
1074    *       conversationsClient.suggestConversationSummary(conversation);
1075    * }
1076    * }</pre>
1077    *
1078    * @param conversation Required. The conversation to fetch suggestion for. Format:
1079    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation
1080    *     ID&gt;`.
1081    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1082    */
suggestConversationSummary( ConversationName conversation)1083   public final SuggestConversationSummaryResponse suggestConversationSummary(
1084       ConversationName conversation) {
1085     SuggestConversationSummaryRequest request =
1086         SuggestConversationSummaryRequest.newBuilder()
1087             .setConversation(conversation == null ? null : conversation.toString())
1088             .build();
1089     return suggestConversationSummary(request);
1090   }
1091 
1092   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1093   /**
1094    * Suggests summary for a conversation based on specific historical messages. The range of the
1095    * messages to be used for summary can be specified in the request.
1096    *
1097    * <p>Sample code:
1098    *
1099    * <pre>{@code
1100    * // This snippet has been automatically generated and should be regarded as a code template only.
1101    * // It will require modifications to work:
1102    * // - It may require correct/in-range values for request initialization.
1103    * // - It may require specifying regional endpoints when creating the service client as shown in
1104    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1105    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1106    *   String conversation =
1107    *       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
1108    *   SuggestConversationSummaryResponse response =
1109    *       conversationsClient.suggestConversationSummary(conversation);
1110    * }
1111    * }</pre>
1112    *
1113    * @param conversation Required. The conversation to fetch suggestion for. Format:
1114    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation
1115    *     ID&gt;`.
1116    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1117    */
suggestConversationSummary(String conversation)1118   public final SuggestConversationSummaryResponse suggestConversationSummary(String conversation) {
1119     SuggestConversationSummaryRequest request =
1120         SuggestConversationSummaryRequest.newBuilder().setConversation(conversation).build();
1121     return suggestConversationSummary(request);
1122   }
1123 
1124   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1125   /**
1126    * Suggests summary for a conversation based on specific historical messages. The range of the
1127    * messages to be used for summary can be specified in the request.
1128    *
1129    * <p>Sample code:
1130    *
1131    * <pre>{@code
1132    * // This snippet has been automatically generated and should be regarded as a code template only.
1133    * // It will require modifications to work:
1134    * // - It may require correct/in-range values for request initialization.
1135    * // - It may require specifying regional endpoints when creating the service client as shown in
1136    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1137    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1138    *   SuggestConversationSummaryRequest request =
1139    *       SuggestConversationSummaryRequest.newBuilder()
1140    *           .setConversation(
1141    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
1142    *                   .toString())
1143    *           .setLatestMessage(
1144    *               MessageName.ofProjectConversationMessageName(
1145    *                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
1146    *                   .toString())
1147    *           .setContextSize(1116903569)
1148    *           .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
1149    *           .build();
1150    *   SuggestConversationSummaryResponse response =
1151    *       conversationsClient.suggestConversationSummary(request);
1152    * }
1153    * }</pre>
1154    *
1155    * @param request The request object containing all of the parameters for the API call.
1156    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1157    */
suggestConversationSummary( SuggestConversationSummaryRequest request)1158   public final SuggestConversationSummaryResponse suggestConversationSummary(
1159       SuggestConversationSummaryRequest request) {
1160     return suggestConversationSummaryCallable().call(request);
1161   }
1162 
1163   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1164   /**
1165    * Suggests summary for a conversation based on specific historical messages. The range of the
1166    * messages to be used for summary can be specified in the request.
1167    *
1168    * <p>Sample code:
1169    *
1170    * <pre>{@code
1171    * // This snippet has been automatically generated and should be regarded as a code template only.
1172    * // It will require modifications to work:
1173    * // - It may require correct/in-range values for request initialization.
1174    * // - It may require specifying regional endpoints when creating the service client as shown in
1175    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1176    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1177    *   SuggestConversationSummaryRequest request =
1178    *       SuggestConversationSummaryRequest.newBuilder()
1179    *           .setConversation(
1180    *               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
1181    *                   .toString())
1182    *           .setLatestMessage(
1183    *               MessageName.ofProjectConversationMessageName(
1184    *                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
1185    *                   .toString())
1186    *           .setContextSize(1116903569)
1187    *           .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
1188    *           .build();
1189    *   ApiFuture<SuggestConversationSummaryResponse> future =
1190    *       conversationsClient.suggestConversationSummaryCallable().futureCall(request);
1191    *   // Do something.
1192    *   SuggestConversationSummaryResponse response = future.get();
1193    * }
1194    * }</pre>
1195    */
1196   public final UnaryCallable<SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummaryCallable()1197       suggestConversationSummaryCallable() {
1198     return stub.suggestConversationSummaryCallable();
1199   }
1200 
1201   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1202   /**
1203    * Generates and returns a summary for a conversation that does not have a resource created for
1204    * it.
1205    *
1206    * <p>Sample code:
1207    *
1208    * <pre>{@code
1209    * // This snippet has been automatically generated and should be regarded as a code template only.
1210    * // It will require modifications to work:
1211    * // - It may require correct/in-range values for request initialization.
1212    * // - It may require specifying regional endpoints when creating the service client as shown in
1213    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1214    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1215    *   GenerateStatelessSummaryRequest request =
1216    *       GenerateStatelessSummaryRequest.newBuilder()
1217    *           .setStatelessConversation(
1218    *               GenerateStatelessSummaryRequest.MinimalConversation.newBuilder().build())
1219    *           .setConversationProfile(ConversationProfile.newBuilder().build())
1220    *           .setLatestMessage(
1221    *               MessageName.ofProjectConversationMessageName(
1222    *                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
1223    *                   .toString())
1224    *           .setMaxContextSize(-1134084212)
1225    *           .build();
1226    *   GenerateStatelessSummaryResponse response =
1227    *       conversationsClient.generateStatelessSummary(request);
1228    * }
1229    * }</pre>
1230    *
1231    * @param request The request object containing all of the parameters for the API call.
1232    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1233    */
generateStatelessSummary( GenerateStatelessSummaryRequest request)1234   public final GenerateStatelessSummaryResponse generateStatelessSummary(
1235       GenerateStatelessSummaryRequest request) {
1236     return generateStatelessSummaryCallable().call(request);
1237   }
1238 
1239   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1240   /**
1241    * Generates and returns a summary for a conversation that does not have a resource created for
1242    * it.
1243    *
1244    * <p>Sample code:
1245    *
1246    * <pre>{@code
1247    * // This snippet has been automatically generated and should be regarded as a code template only.
1248    * // It will require modifications to work:
1249    * // - It may require correct/in-range values for request initialization.
1250    * // - It may require specifying regional endpoints when creating the service client as shown in
1251    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1252    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1253    *   GenerateStatelessSummaryRequest request =
1254    *       GenerateStatelessSummaryRequest.newBuilder()
1255    *           .setStatelessConversation(
1256    *               GenerateStatelessSummaryRequest.MinimalConversation.newBuilder().build())
1257    *           .setConversationProfile(ConversationProfile.newBuilder().build())
1258    *           .setLatestMessage(
1259    *               MessageName.ofProjectConversationMessageName(
1260    *                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
1261    *                   .toString())
1262    *           .setMaxContextSize(-1134084212)
1263    *           .build();
1264    *   ApiFuture<GenerateStatelessSummaryResponse> future =
1265    *       conversationsClient.generateStatelessSummaryCallable().futureCall(request);
1266    *   // Do something.
1267    *   GenerateStatelessSummaryResponse response = future.get();
1268    * }
1269    * }</pre>
1270    */
1271   public final UnaryCallable<GenerateStatelessSummaryRequest, GenerateStatelessSummaryResponse>
generateStatelessSummaryCallable()1272       generateStatelessSummaryCallable() {
1273     return stub.generateStatelessSummaryCallable();
1274   }
1275 
1276   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1277   /**
1278    * Lists information about the supported locations for this service.
1279    *
1280    * <p>Sample code:
1281    *
1282    * <pre>{@code
1283    * // This snippet has been automatically generated and should be regarded as a code template only.
1284    * // It will require modifications to work:
1285    * // - It may require correct/in-range values for request initialization.
1286    * // - It may require specifying regional endpoints when creating the service client as shown in
1287    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1288    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1289    *   ListLocationsRequest request =
1290    *       ListLocationsRequest.newBuilder()
1291    *           .setName("name3373707")
1292    *           .setFilter("filter-1274492040")
1293    *           .setPageSize(883849137)
1294    *           .setPageToken("pageToken873572522")
1295    *           .build();
1296    *   for (Location element : conversationsClient.listLocations(request).iterateAll()) {
1297    *     // doThingsWith(element);
1298    *   }
1299    * }
1300    * }</pre>
1301    *
1302    * @param request The request object containing all of the parameters for the API call.
1303    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1304    */
listLocations(ListLocationsRequest request)1305   public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
1306     return listLocationsPagedCallable().call(request);
1307   }
1308 
1309   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1310   /**
1311    * Lists information about the supported locations for this service.
1312    *
1313    * <p>Sample code:
1314    *
1315    * <pre>{@code
1316    * // This snippet has been automatically generated and should be regarded as a code template only.
1317    * // It will require modifications to work:
1318    * // - It may require correct/in-range values for request initialization.
1319    * // - It may require specifying regional endpoints when creating the service client as shown in
1320    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1321    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1322    *   ListLocationsRequest request =
1323    *       ListLocationsRequest.newBuilder()
1324    *           .setName("name3373707")
1325    *           .setFilter("filter-1274492040")
1326    *           .setPageSize(883849137)
1327    *           .setPageToken("pageToken873572522")
1328    *           .build();
1329    *   ApiFuture<Location> future =
1330    *       conversationsClient.listLocationsPagedCallable().futureCall(request);
1331    *   // Do something.
1332    *   for (Location element : future.get().iterateAll()) {
1333    *     // doThingsWith(element);
1334    *   }
1335    * }
1336    * }</pre>
1337    */
1338   public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()1339       listLocationsPagedCallable() {
1340     return stub.listLocationsPagedCallable();
1341   }
1342 
1343   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1344   /**
1345    * Lists information about the supported locations for this service.
1346    *
1347    * <p>Sample code:
1348    *
1349    * <pre>{@code
1350    * // This snippet has been automatically generated and should be regarded as a code template only.
1351    * // It will require modifications to work:
1352    * // - It may require correct/in-range values for request initialization.
1353    * // - It may require specifying regional endpoints when creating the service client as shown in
1354    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1355    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1356    *   ListLocationsRequest request =
1357    *       ListLocationsRequest.newBuilder()
1358    *           .setName("name3373707")
1359    *           .setFilter("filter-1274492040")
1360    *           .setPageSize(883849137)
1361    *           .setPageToken("pageToken873572522")
1362    *           .build();
1363    *   while (true) {
1364    *     ListLocationsResponse response = conversationsClient.listLocationsCallable().call(request);
1365    *     for (Location element : response.getLocationsList()) {
1366    *       // doThingsWith(element);
1367    *     }
1368    *     String nextPageToken = response.getNextPageToken();
1369    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
1370    *       request = request.toBuilder().setPageToken(nextPageToken).build();
1371    *     } else {
1372    *       break;
1373    *     }
1374    *   }
1375    * }
1376    * }</pre>
1377    */
listLocationsCallable()1378   public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
1379     return stub.listLocationsCallable();
1380   }
1381 
1382   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1383   /**
1384    * Gets information about a location.
1385    *
1386    * <p>Sample code:
1387    *
1388    * <pre>{@code
1389    * // This snippet has been automatically generated and should be regarded as a code template only.
1390    * // It will require modifications to work:
1391    * // - It may require correct/in-range values for request initialization.
1392    * // - It may require specifying regional endpoints when creating the service client as shown in
1393    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1394    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1395    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
1396    *   Location response = conversationsClient.getLocation(request);
1397    * }
1398    * }</pre>
1399    *
1400    * @param request The request object containing all of the parameters for the API call.
1401    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1402    */
getLocation(GetLocationRequest request)1403   public final Location getLocation(GetLocationRequest request) {
1404     return getLocationCallable().call(request);
1405   }
1406 
1407   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1408   /**
1409    * Gets information about a location.
1410    *
1411    * <p>Sample code:
1412    *
1413    * <pre>{@code
1414    * // This snippet has been automatically generated and should be regarded as a code template only.
1415    * // It will require modifications to work:
1416    * // - It may require correct/in-range values for request initialization.
1417    * // - It may require specifying regional endpoints when creating the service client as shown in
1418    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1419    * try (ConversationsClient conversationsClient = ConversationsClient.create()) {
1420    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
1421    *   ApiFuture<Location> future = conversationsClient.getLocationCallable().futureCall(request);
1422    *   // Do something.
1423    *   Location response = future.get();
1424    * }
1425    * }</pre>
1426    */
getLocationCallable()1427   public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
1428     return stub.getLocationCallable();
1429   }
1430 
1431   @Override
close()1432   public final void close() {
1433     stub.close();
1434   }
1435 
1436   @Override
shutdown()1437   public void shutdown() {
1438     stub.shutdown();
1439   }
1440 
1441   @Override
isShutdown()1442   public boolean isShutdown() {
1443     return stub.isShutdown();
1444   }
1445 
1446   @Override
isTerminated()1447   public boolean isTerminated() {
1448     return stub.isTerminated();
1449   }
1450 
1451   @Override
shutdownNow()1452   public void shutdownNow() {
1453     stub.shutdownNow();
1454   }
1455 
1456   @Override
awaitTermination(long duration, TimeUnit unit)1457   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1458     return stub.awaitTermination(duration, unit);
1459   }
1460 
1461   public static class ListConversationsPagedResponse
1462       extends AbstractPagedListResponse<
1463           ListConversationsRequest,
1464           ListConversationsResponse,
1465           Conversation,
1466           ListConversationsPage,
1467           ListConversationsFixedSizeCollection> {
1468 
createAsync( PageContext<ListConversationsRequest, ListConversationsResponse, Conversation> context, ApiFuture<ListConversationsResponse> futureResponse)1469     public static ApiFuture<ListConversationsPagedResponse> createAsync(
1470         PageContext<ListConversationsRequest, ListConversationsResponse, Conversation> context,
1471         ApiFuture<ListConversationsResponse> futureResponse) {
1472       ApiFuture<ListConversationsPage> futurePage =
1473           ListConversationsPage.createEmptyPage().createPageAsync(context, futureResponse);
1474       return ApiFutures.transform(
1475           futurePage,
1476           input -> new ListConversationsPagedResponse(input),
1477           MoreExecutors.directExecutor());
1478     }
1479 
ListConversationsPagedResponse(ListConversationsPage page)1480     private ListConversationsPagedResponse(ListConversationsPage page) {
1481       super(page, ListConversationsFixedSizeCollection.createEmptyCollection());
1482     }
1483   }
1484 
1485   public static class ListConversationsPage
1486       extends AbstractPage<
1487           ListConversationsRequest,
1488           ListConversationsResponse,
1489           Conversation,
1490           ListConversationsPage> {
1491 
ListConversationsPage( PageContext<ListConversationsRequest, ListConversationsResponse, Conversation> context, ListConversationsResponse response)1492     private ListConversationsPage(
1493         PageContext<ListConversationsRequest, ListConversationsResponse, Conversation> context,
1494         ListConversationsResponse response) {
1495       super(context, response);
1496     }
1497 
createEmptyPage()1498     private static ListConversationsPage createEmptyPage() {
1499       return new ListConversationsPage(null, null);
1500     }
1501 
1502     @Override
createPage( PageContext<ListConversationsRequest, ListConversationsResponse, Conversation> context, ListConversationsResponse response)1503     protected ListConversationsPage createPage(
1504         PageContext<ListConversationsRequest, ListConversationsResponse, Conversation> context,
1505         ListConversationsResponse response) {
1506       return new ListConversationsPage(context, response);
1507     }
1508 
1509     @Override
createPageAsync( PageContext<ListConversationsRequest, ListConversationsResponse, Conversation> context, ApiFuture<ListConversationsResponse> futureResponse)1510     public ApiFuture<ListConversationsPage> createPageAsync(
1511         PageContext<ListConversationsRequest, ListConversationsResponse, Conversation> context,
1512         ApiFuture<ListConversationsResponse> futureResponse) {
1513       return super.createPageAsync(context, futureResponse);
1514     }
1515   }
1516 
1517   public static class ListConversationsFixedSizeCollection
1518       extends AbstractFixedSizeCollection<
1519           ListConversationsRequest,
1520           ListConversationsResponse,
1521           Conversation,
1522           ListConversationsPage,
1523           ListConversationsFixedSizeCollection> {
1524 
ListConversationsFixedSizeCollection( List<ListConversationsPage> pages, int collectionSize)1525     private ListConversationsFixedSizeCollection(
1526         List<ListConversationsPage> pages, int collectionSize) {
1527       super(pages, collectionSize);
1528     }
1529 
createEmptyCollection()1530     private static ListConversationsFixedSizeCollection createEmptyCollection() {
1531       return new ListConversationsFixedSizeCollection(null, 0);
1532     }
1533 
1534     @Override
createCollection( List<ListConversationsPage> pages, int collectionSize)1535     protected ListConversationsFixedSizeCollection createCollection(
1536         List<ListConversationsPage> pages, int collectionSize) {
1537       return new ListConversationsFixedSizeCollection(pages, collectionSize);
1538     }
1539   }
1540 
1541   public static class ListMessagesPagedResponse
1542       extends AbstractPagedListResponse<
1543           ListMessagesRequest,
1544           ListMessagesResponse,
1545           Message,
1546           ListMessagesPage,
1547           ListMessagesFixedSizeCollection> {
1548 
createAsync( PageContext<ListMessagesRequest, ListMessagesResponse, Message> context, ApiFuture<ListMessagesResponse> futureResponse)1549     public static ApiFuture<ListMessagesPagedResponse> createAsync(
1550         PageContext<ListMessagesRequest, ListMessagesResponse, Message> context,
1551         ApiFuture<ListMessagesResponse> futureResponse) {
1552       ApiFuture<ListMessagesPage> futurePage =
1553           ListMessagesPage.createEmptyPage().createPageAsync(context, futureResponse);
1554       return ApiFutures.transform(
1555           futurePage,
1556           input -> new ListMessagesPagedResponse(input),
1557           MoreExecutors.directExecutor());
1558     }
1559 
ListMessagesPagedResponse(ListMessagesPage page)1560     private ListMessagesPagedResponse(ListMessagesPage page) {
1561       super(page, ListMessagesFixedSizeCollection.createEmptyCollection());
1562     }
1563   }
1564 
1565   public static class ListMessagesPage
1566       extends AbstractPage<ListMessagesRequest, ListMessagesResponse, Message, ListMessagesPage> {
1567 
ListMessagesPage( PageContext<ListMessagesRequest, ListMessagesResponse, Message> context, ListMessagesResponse response)1568     private ListMessagesPage(
1569         PageContext<ListMessagesRequest, ListMessagesResponse, Message> context,
1570         ListMessagesResponse response) {
1571       super(context, response);
1572     }
1573 
createEmptyPage()1574     private static ListMessagesPage createEmptyPage() {
1575       return new ListMessagesPage(null, null);
1576     }
1577 
1578     @Override
createPage( PageContext<ListMessagesRequest, ListMessagesResponse, Message> context, ListMessagesResponse response)1579     protected ListMessagesPage createPage(
1580         PageContext<ListMessagesRequest, ListMessagesResponse, Message> context,
1581         ListMessagesResponse response) {
1582       return new ListMessagesPage(context, response);
1583     }
1584 
1585     @Override
createPageAsync( PageContext<ListMessagesRequest, ListMessagesResponse, Message> context, ApiFuture<ListMessagesResponse> futureResponse)1586     public ApiFuture<ListMessagesPage> createPageAsync(
1587         PageContext<ListMessagesRequest, ListMessagesResponse, Message> context,
1588         ApiFuture<ListMessagesResponse> futureResponse) {
1589       return super.createPageAsync(context, futureResponse);
1590     }
1591   }
1592 
1593   public static class ListMessagesFixedSizeCollection
1594       extends AbstractFixedSizeCollection<
1595           ListMessagesRequest,
1596           ListMessagesResponse,
1597           Message,
1598           ListMessagesPage,
1599           ListMessagesFixedSizeCollection> {
1600 
ListMessagesFixedSizeCollection(List<ListMessagesPage> pages, int collectionSize)1601     private ListMessagesFixedSizeCollection(List<ListMessagesPage> pages, int collectionSize) {
1602       super(pages, collectionSize);
1603     }
1604 
createEmptyCollection()1605     private static ListMessagesFixedSizeCollection createEmptyCollection() {
1606       return new ListMessagesFixedSizeCollection(null, 0);
1607     }
1608 
1609     @Override
createCollection( List<ListMessagesPage> pages, int collectionSize)1610     protected ListMessagesFixedSizeCollection createCollection(
1611         List<ListMessagesPage> pages, int collectionSize) {
1612       return new ListMessagesFixedSizeCollection(pages, collectionSize);
1613     }
1614   }
1615 
1616   public static class ListLocationsPagedResponse
1617       extends AbstractPagedListResponse<
1618           ListLocationsRequest,
1619           ListLocationsResponse,
1620           Location,
1621           ListLocationsPage,
1622           ListLocationsFixedSizeCollection> {
1623 
createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1624     public static ApiFuture<ListLocationsPagedResponse> createAsync(
1625         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1626         ApiFuture<ListLocationsResponse> futureResponse) {
1627       ApiFuture<ListLocationsPage> futurePage =
1628           ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
1629       return ApiFutures.transform(
1630           futurePage,
1631           input -> new ListLocationsPagedResponse(input),
1632           MoreExecutors.directExecutor());
1633     }
1634 
ListLocationsPagedResponse(ListLocationsPage page)1635     private ListLocationsPagedResponse(ListLocationsPage page) {
1636       super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
1637     }
1638   }
1639 
1640   public static class ListLocationsPage
1641       extends AbstractPage<
1642           ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
1643 
ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1644     private ListLocationsPage(
1645         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1646         ListLocationsResponse response) {
1647       super(context, response);
1648     }
1649 
createEmptyPage()1650     private static ListLocationsPage createEmptyPage() {
1651       return new ListLocationsPage(null, null);
1652     }
1653 
1654     @Override
createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1655     protected ListLocationsPage createPage(
1656         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1657         ListLocationsResponse response) {
1658       return new ListLocationsPage(context, response);
1659     }
1660 
1661     @Override
createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1662     public ApiFuture<ListLocationsPage> createPageAsync(
1663         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1664         ApiFuture<ListLocationsResponse> futureResponse) {
1665       return super.createPageAsync(context, futureResponse);
1666     }
1667   }
1668 
1669   public static class ListLocationsFixedSizeCollection
1670       extends AbstractFixedSizeCollection<
1671           ListLocationsRequest,
1672           ListLocationsResponse,
1673           Location,
1674           ListLocationsPage,
1675           ListLocationsFixedSizeCollection> {
1676 
ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1677     private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
1678       super(pages, collectionSize);
1679     }
1680 
createEmptyCollection()1681     private static ListLocationsFixedSizeCollection createEmptyCollection() {
1682       return new ListLocationsFixedSizeCollection(null, 0);
1683     }
1684 
1685     @Override
createCollection( List<ListLocationsPage> pages, int collectionSize)1686     protected ListLocationsFixedSizeCollection createCollection(
1687         List<ListLocationsPage> pages, int collectionSize) {
1688       return new ListLocationsFixedSizeCollection(pages, collectionSize);
1689     }
1690   }
1691 }
1692