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