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