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