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