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.compute.v1; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.gax.core.BackgroundResource; 22 import com.google.api.gax.paging.AbstractFixedSizeCollection; 23 import com.google.api.gax.paging.AbstractPage; 24 import com.google.api.gax.paging.AbstractPagedListResponse; 25 import com.google.api.gax.rpc.PageContext; 26 import com.google.api.gax.rpc.UnaryCallable; 27 import com.google.cloud.compute.v1.stub.RegionOperationsStub; 28 import com.google.cloud.compute.v1.stub.RegionOperationsStubSettings; 29 import com.google.common.util.concurrent.MoreExecutors; 30 import java.io.IOException; 31 import java.util.List; 32 import java.util.concurrent.TimeUnit; 33 import javax.annotation.Generated; 34 35 // AUTO-GENERATED DOCUMENTATION AND CLASS. 36 /** 37 * Service Description: The RegionOperations API. 38 * 39 * <p>This class provides the ability to make remote calls to the backing service through method 40 * calls that map to API methods. Sample code to get started: 41 * 42 * <pre>{@code 43 * // This snippet has been automatically generated and should be regarded as a code template only. 44 * // It will require modifications to work: 45 * // - It may require correct/in-range values for request initialization. 46 * // - It may require specifying regional endpoints when creating the service client as shown in 47 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 48 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 49 * String project = "project-309310695"; 50 * String region = "region-934795532"; 51 * String operation = "operation1662702951"; 52 * DeleteRegionOperationResponse response = 53 * regionOperationsClient.delete(project, region, operation); 54 * } 55 * }</pre> 56 * 57 * <p>Note: close() needs to be called on the RegionOperationsClient object to clean up resources 58 * such as threads. In the example above, try-with-resources is used, which automatically calls 59 * close(). 60 * 61 * <p>The surface of this class includes several types of Java methods for each of the API's 62 * methods: 63 * 64 * <ol> 65 * <li>A "flattened" method. With this type of method, the fields of the request type have been 66 * converted into function parameters. It may be the case that not all fields are available as 67 * parameters, and not every API method will have a flattened method entry point. 68 * <li>A "request object" method. This type of method only takes one parameter, a request object, 69 * which must be constructed before the call. Not every API method will have a request object 70 * method. 71 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 72 * callable object, which can be used to initiate calls to the service. 73 * </ol> 74 * 75 * <p>See the individual methods for example code. 76 * 77 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 78 * these names, this class includes a format method for each type of name, and additionally a parse 79 * method to extract the individual identifiers contained within names that are returned. 80 * 81 * <p>This class can be customized by passing in a custom instance of RegionOperationsSettings to 82 * create(). For example: 83 * 84 * <p>To customize credentials: 85 * 86 * <pre>{@code 87 * // This snippet has been automatically generated and should be regarded as a code template only. 88 * // It will require modifications to work: 89 * // - It may require correct/in-range values for request initialization. 90 * // - It may require specifying regional endpoints when creating the service client as shown in 91 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 92 * RegionOperationsSettings regionOperationsSettings = 93 * RegionOperationsSettings.newBuilder() 94 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 95 * .build(); 96 * RegionOperationsClient regionOperationsClient = 97 * RegionOperationsClient.create(regionOperationsSettings); 98 * }</pre> 99 * 100 * <p>To customize the endpoint: 101 * 102 * <pre>{@code 103 * // This snippet has been automatically generated and should be regarded as a code template only. 104 * // It will require modifications to work: 105 * // - It may require correct/in-range values for request initialization. 106 * // - It may require specifying regional endpoints when creating the service client as shown in 107 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 108 * RegionOperationsSettings regionOperationsSettings = 109 * RegionOperationsSettings.newBuilder().setEndpoint(myEndpoint).build(); 110 * RegionOperationsClient regionOperationsClient = 111 * RegionOperationsClient.create(regionOperationsSettings); 112 * }</pre> 113 * 114 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 115 */ 116 @Generated("by gapic-generator-java") 117 public class RegionOperationsClient implements BackgroundResource { 118 private final RegionOperationsSettings settings; 119 private final RegionOperationsStub stub; 120 121 /** Constructs an instance of RegionOperationsClient with default settings. */ create()122 public static final RegionOperationsClient create() throws IOException { 123 return create(RegionOperationsSettings.newBuilder().build()); 124 } 125 126 /** 127 * Constructs an instance of RegionOperationsClient, using the given settings. The channels are 128 * created based on the settings passed in, or defaults for any settings that are not set. 129 */ create(RegionOperationsSettings settings)130 public static final RegionOperationsClient create(RegionOperationsSettings settings) 131 throws IOException { 132 return new RegionOperationsClient(settings); 133 } 134 135 /** 136 * Constructs an instance of RegionOperationsClient, using the given stub for making calls. This 137 * is for advanced usage - prefer using create(RegionOperationsSettings). 138 */ create(RegionOperationsStub stub)139 public static final RegionOperationsClient create(RegionOperationsStub stub) { 140 return new RegionOperationsClient(stub); 141 } 142 143 /** 144 * Constructs an instance of RegionOperationsClient, using the given settings. This is protected 145 * so that it is easy to make a subclass, but otherwise, the static factory methods should be 146 * preferred. 147 */ RegionOperationsClient(RegionOperationsSettings settings)148 protected RegionOperationsClient(RegionOperationsSettings settings) throws IOException { 149 this.settings = settings; 150 this.stub = ((RegionOperationsStubSettings) settings.getStubSettings()).createStub(); 151 } 152 RegionOperationsClient(RegionOperationsStub stub)153 protected RegionOperationsClient(RegionOperationsStub stub) { 154 this.settings = null; 155 this.stub = stub; 156 } 157 getSettings()158 public final RegionOperationsSettings getSettings() { 159 return settings; 160 } 161 getStub()162 public RegionOperationsStub getStub() { 163 return stub; 164 } 165 166 // AUTO-GENERATED DOCUMENTATION AND METHOD. 167 /** 168 * Deletes the specified region-specific Operations resource. 169 * 170 * <p>Sample code: 171 * 172 * <pre>{@code 173 * // This snippet has been automatically generated and should be regarded as a code template only. 174 * // It will require modifications to work: 175 * // - It may require correct/in-range values for request initialization. 176 * // - It may require specifying regional endpoints when creating the service client as shown in 177 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 178 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 179 * String project = "project-309310695"; 180 * String region = "region-934795532"; 181 * String operation = "operation1662702951"; 182 * DeleteRegionOperationResponse response = 183 * regionOperationsClient.delete(project, region, operation); 184 * } 185 * }</pre> 186 * 187 * @param project Project ID for this request. 188 * @param region Name of the region for this request. 189 * @param operation Name of the Operations resource to delete. 190 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 191 */ delete( String project, String region, String operation)192 public final DeleteRegionOperationResponse delete( 193 String project, String region, String operation) { 194 DeleteRegionOperationRequest request = 195 DeleteRegionOperationRequest.newBuilder() 196 .setProject(project) 197 .setRegion(region) 198 .setOperation(operation) 199 .build(); 200 return delete(request); 201 } 202 203 // AUTO-GENERATED DOCUMENTATION AND METHOD. 204 /** 205 * Deletes the specified region-specific Operations resource. 206 * 207 * <p>Sample code: 208 * 209 * <pre>{@code 210 * // This snippet has been automatically generated and should be regarded as a code template only. 211 * // It will require modifications to work: 212 * // - It may require correct/in-range values for request initialization. 213 * // - It may require specifying regional endpoints when creating the service client as shown in 214 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 215 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 216 * DeleteRegionOperationRequest request = 217 * DeleteRegionOperationRequest.newBuilder() 218 * .setOperation("operation1662702951") 219 * .setProject("project-309310695") 220 * .setRegion("region-934795532") 221 * .build(); 222 * DeleteRegionOperationResponse response = regionOperationsClient.delete(request); 223 * } 224 * }</pre> 225 * 226 * @param request The request object containing all of the parameters for the API call. 227 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 228 */ delete(DeleteRegionOperationRequest request)229 public final DeleteRegionOperationResponse delete(DeleteRegionOperationRequest request) { 230 return deleteCallable().call(request); 231 } 232 233 // AUTO-GENERATED DOCUMENTATION AND METHOD. 234 /** 235 * Deletes the specified region-specific Operations resource. 236 * 237 * <p>Sample code: 238 * 239 * <pre>{@code 240 * // This snippet has been automatically generated and should be regarded as a code template only. 241 * // It will require modifications to work: 242 * // - It may require correct/in-range values for request initialization. 243 * // - It may require specifying regional endpoints when creating the service client as shown in 244 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 245 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 246 * DeleteRegionOperationRequest request = 247 * DeleteRegionOperationRequest.newBuilder() 248 * .setOperation("operation1662702951") 249 * .setProject("project-309310695") 250 * .setRegion("region-934795532") 251 * .build(); 252 * ApiFuture<DeleteRegionOperationResponse> future = 253 * regionOperationsClient.deleteCallable().futureCall(request); 254 * // Do something. 255 * DeleteRegionOperationResponse response = future.get(); 256 * } 257 * }</pre> 258 */ 259 public final UnaryCallable<DeleteRegionOperationRequest, DeleteRegionOperationResponse> deleteCallable()260 deleteCallable() { 261 return stub.deleteCallable(); 262 } 263 264 // AUTO-GENERATED DOCUMENTATION AND METHOD. 265 /** 266 * Retrieves the specified region-specific Operations resource. 267 * 268 * <p>Sample code: 269 * 270 * <pre>{@code 271 * // This snippet has been automatically generated and should be regarded as a code template only. 272 * // It will require modifications to work: 273 * // - It may require correct/in-range values for request initialization. 274 * // - It may require specifying regional endpoints when creating the service client as shown in 275 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 276 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 277 * String project = "project-309310695"; 278 * String region = "region-934795532"; 279 * String operation = "operation1662702951"; 280 * Operation response = regionOperationsClient.get(project, region, operation); 281 * } 282 * }</pre> 283 * 284 * @param project Project ID for this request. 285 * @param region Name of the region for this request. 286 * @param operation Name of the Operations resource to return. 287 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 288 */ get(String project, String region, String operation)289 public final Operation get(String project, String region, String operation) { 290 GetRegionOperationRequest request = 291 GetRegionOperationRequest.newBuilder() 292 .setProject(project) 293 .setRegion(region) 294 .setOperation(operation) 295 .build(); 296 return get(request); 297 } 298 299 // AUTO-GENERATED DOCUMENTATION AND METHOD. 300 /** 301 * Retrieves the specified region-specific Operations resource. 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 (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 312 * GetRegionOperationRequest request = 313 * GetRegionOperationRequest.newBuilder() 314 * .setOperation("operation1662702951") 315 * .setProject("project-309310695") 316 * .setRegion("region-934795532") 317 * .build(); 318 * Operation response = regionOperationsClient.get(request); 319 * } 320 * }</pre> 321 * 322 * @param request The request object containing all of the parameters for the API call. 323 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 324 */ get(GetRegionOperationRequest request)325 public final Operation get(GetRegionOperationRequest request) { 326 return getCallable().call(request); 327 } 328 329 // AUTO-GENERATED DOCUMENTATION AND METHOD. 330 /** 331 * Retrieves the specified region-specific Operations resource. 332 * 333 * <p>Sample code: 334 * 335 * <pre>{@code 336 * // This snippet has been automatically generated and should be regarded as a code template only. 337 * // It will require modifications to work: 338 * // - It may require correct/in-range values for request initialization. 339 * // - It may require specifying regional endpoints when creating the service client as shown in 340 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 341 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 342 * GetRegionOperationRequest request = 343 * GetRegionOperationRequest.newBuilder() 344 * .setOperation("operation1662702951") 345 * .setProject("project-309310695") 346 * .setRegion("region-934795532") 347 * .build(); 348 * ApiFuture<Operation> future = regionOperationsClient.getCallable().futureCall(request); 349 * // Do something. 350 * Operation response = future.get(); 351 * } 352 * }</pre> 353 */ getCallable()354 public final UnaryCallable<GetRegionOperationRequest, Operation> getCallable() { 355 return stub.getCallable(); 356 } 357 358 // AUTO-GENERATED DOCUMENTATION AND METHOD. 359 /** 360 * Retrieves a list of Operation resources contained within the specified region. 361 * 362 * <p>Sample code: 363 * 364 * <pre>{@code 365 * // This snippet has been automatically generated and should be regarded as a code template only. 366 * // It will require modifications to work: 367 * // - It may require correct/in-range values for request initialization. 368 * // - It may require specifying regional endpoints when creating the service client as shown in 369 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 370 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 371 * String project = "project-309310695"; 372 * String region = "region-934795532"; 373 * for (Operation element : regionOperationsClient.list(project, region).iterateAll()) { 374 * // doThingsWith(element); 375 * } 376 * } 377 * }</pre> 378 * 379 * @param project Project ID for this request. 380 * @param region Name of the region for this request. 381 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 382 */ list(String project, String region)383 public final ListPagedResponse list(String project, String region) { 384 ListRegionOperationsRequest request = 385 ListRegionOperationsRequest.newBuilder().setProject(project).setRegion(region).build(); 386 return list(request); 387 } 388 389 // AUTO-GENERATED DOCUMENTATION AND METHOD. 390 /** 391 * Retrieves a list of Operation resources contained within the specified region. 392 * 393 * <p>Sample code: 394 * 395 * <pre>{@code 396 * // This snippet has been automatically generated and should be regarded as a code template only. 397 * // It will require modifications to work: 398 * // - It may require correct/in-range values for request initialization. 399 * // - It may require specifying regional endpoints when creating the service client as shown in 400 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 401 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 402 * ListRegionOperationsRequest request = 403 * ListRegionOperationsRequest.newBuilder() 404 * .setFilter("filter-1274492040") 405 * .setMaxResults(1128457243) 406 * .setOrderBy("orderBy-1207110587") 407 * .setPageToken("pageToken873572522") 408 * .setProject("project-309310695") 409 * .setRegion("region-934795532") 410 * .setReturnPartialSuccess(true) 411 * .build(); 412 * for (Operation element : regionOperationsClient.list(request).iterateAll()) { 413 * // doThingsWith(element); 414 * } 415 * } 416 * }</pre> 417 * 418 * @param request The request object containing all of the parameters for the API call. 419 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 420 */ list(ListRegionOperationsRequest request)421 public final ListPagedResponse list(ListRegionOperationsRequest request) { 422 return listPagedCallable().call(request); 423 } 424 425 // AUTO-GENERATED DOCUMENTATION AND METHOD. 426 /** 427 * Retrieves a list of Operation resources contained within the specified region. 428 * 429 * <p>Sample code: 430 * 431 * <pre>{@code 432 * // This snippet has been automatically generated and should be regarded as a code template only. 433 * // It will require modifications to work: 434 * // - It may require correct/in-range values for request initialization. 435 * // - It may require specifying regional endpoints when creating the service client as shown in 436 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 437 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 438 * ListRegionOperationsRequest request = 439 * ListRegionOperationsRequest.newBuilder() 440 * .setFilter("filter-1274492040") 441 * .setMaxResults(1128457243) 442 * .setOrderBy("orderBy-1207110587") 443 * .setPageToken("pageToken873572522") 444 * .setProject("project-309310695") 445 * .setRegion("region-934795532") 446 * .setReturnPartialSuccess(true) 447 * .build(); 448 * ApiFuture<Operation> future = regionOperationsClient.listPagedCallable().futureCall(request); 449 * // Do something. 450 * for (Operation element : future.get().iterateAll()) { 451 * // doThingsWith(element); 452 * } 453 * } 454 * }</pre> 455 */ listPagedCallable()456 public final UnaryCallable<ListRegionOperationsRequest, ListPagedResponse> listPagedCallable() { 457 return stub.listPagedCallable(); 458 } 459 460 // AUTO-GENERATED DOCUMENTATION AND METHOD. 461 /** 462 * Retrieves a list of Operation resources contained within the specified region. 463 * 464 * <p>Sample code: 465 * 466 * <pre>{@code 467 * // This snippet has been automatically generated and should be regarded as a code template only. 468 * // It will require modifications to work: 469 * // - It may require correct/in-range values for request initialization. 470 * // - It may require specifying regional endpoints when creating the service client as shown in 471 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 472 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 473 * ListRegionOperationsRequest request = 474 * ListRegionOperationsRequest.newBuilder() 475 * .setFilter("filter-1274492040") 476 * .setMaxResults(1128457243) 477 * .setOrderBy("orderBy-1207110587") 478 * .setPageToken("pageToken873572522") 479 * .setProject("project-309310695") 480 * .setRegion("region-934795532") 481 * .setReturnPartialSuccess(true) 482 * .build(); 483 * while (true) { 484 * OperationList response = regionOperationsClient.listCallable().call(request); 485 * for (Operation element : response.getItemsList()) { 486 * // doThingsWith(element); 487 * } 488 * String nextPageToken = response.getNextPageToken(); 489 * if (!Strings.isNullOrEmpty(nextPageToken)) { 490 * request = request.toBuilder().setPageToken(nextPageToken).build(); 491 * } else { 492 * break; 493 * } 494 * } 495 * } 496 * }</pre> 497 */ listCallable()498 public final UnaryCallable<ListRegionOperationsRequest, OperationList> listCallable() { 499 return stub.listCallable(); 500 } 501 502 // AUTO-GENERATED DOCUMENTATION AND METHOD. 503 /** 504 * Waits for the specified Operation resource to return as `DONE` or for the request to approach 505 * the 2 minute deadline, and retrieves the specified Operation resource. This method differs from 506 * the `GET` method in that it waits for no more than the default deadline (2 minutes) and then 507 * returns the current state of the operation, which might be `DONE` or still in progress. This 508 * method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is 509 * overloaded, the request might return before the default deadline is reached, or might return 510 * after zero seconds. - If the default deadline is reached, there is no guarantee that the 511 * operation is actually done when the method returns. Be prepared to retry if the operation is 512 * not `DONE`. 513 * 514 * <p>Sample code: 515 * 516 * <pre>{@code 517 * // This snippet has been automatically generated and should be regarded as a code template only. 518 * // It will require modifications to work: 519 * // - It may require correct/in-range values for request initialization. 520 * // - It may require specifying regional endpoints when creating the service client as shown in 521 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 522 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 523 * String project = "project-309310695"; 524 * String region = "region-934795532"; 525 * String operation = "operation1662702951"; 526 * Operation response = regionOperationsClient.wait(project, region, operation); 527 * } 528 * }</pre> 529 * 530 * @param project Project ID for this request. 531 * @param region Name of the region for this request. 532 * @param operation Name of the Operations resource to return. 533 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 534 */ wait(String project, String region, String operation)535 public final Operation wait(String project, String region, String operation) { 536 WaitRegionOperationRequest request = 537 WaitRegionOperationRequest.newBuilder() 538 .setProject(project) 539 .setRegion(region) 540 .setOperation(operation) 541 .build(); 542 return wait(request); 543 } 544 545 // AUTO-GENERATED DOCUMENTATION AND METHOD. 546 /** 547 * Waits for the specified Operation resource to return as `DONE` or for the request to approach 548 * the 2 minute deadline, and retrieves the specified Operation resource. This method differs from 549 * the `GET` method in that it waits for no more than the default deadline (2 minutes) and then 550 * returns the current state of the operation, which might be `DONE` or still in progress. This 551 * method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is 552 * overloaded, the request might return before the default deadline is reached, or might return 553 * after zero seconds. - If the default deadline is reached, there is no guarantee that the 554 * operation is actually done when the method returns. Be prepared to retry if the operation is 555 * not `DONE`. 556 * 557 * <p>Sample code: 558 * 559 * <pre>{@code 560 * // This snippet has been automatically generated and should be regarded as a code template only. 561 * // It will require modifications to work: 562 * // - It may require correct/in-range values for request initialization. 563 * // - It may require specifying regional endpoints when creating the service client as shown in 564 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 565 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 566 * WaitRegionOperationRequest request = 567 * WaitRegionOperationRequest.newBuilder() 568 * .setOperation("operation1662702951") 569 * .setProject("project-309310695") 570 * .setRegion("region-934795532") 571 * .build(); 572 * Operation response = regionOperationsClient.wait(request); 573 * } 574 * }</pre> 575 * 576 * @param request The request object containing all of the parameters for the API call. 577 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 578 */ wait(WaitRegionOperationRequest request)579 public final Operation wait(WaitRegionOperationRequest request) { 580 return waitCallable().call(request); 581 } 582 583 // AUTO-GENERATED DOCUMENTATION AND METHOD. 584 /** 585 * Waits for the specified Operation resource to return as `DONE` or for the request to approach 586 * the 2 minute deadline, and retrieves the specified Operation resource. This method differs from 587 * the `GET` method in that it waits for no more than the default deadline (2 minutes) and then 588 * returns the current state of the operation, which might be `DONE` or still in progress. This 589 * method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is 590 * overloaded, the request might return before the default deadline is reached, or might return 591 * after zero seconds. - If the default deadline is reached, there is no guarantee that the 592 * operation is actually done when the method returns. Be prepared to retry if the operation is 593 * not `DONE`. 594 * 595 * <p>Sample code: 596 * 597 * <pre>{@code 598 * // This snippet has been automatically generated and should be regarded as a code template only. 599 * // It will require modifications to work: 600 * // - It may require correct/in-range values for request initialization. 601 * // - It may require specifying regional endpoints when creating the service client as shown in 602 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 603 * try (RegionOperationsClient regionOperationsClient = RegionOperationsClient.create()) { 604 * WaitRegionOperationRequest request = 605 * WaitRegionOperationRequest.newBuilder() 606 * .setOperation("operation1662702951") 607 * .setProject("project-309310695") 608 * .setRegion("region-934795532") 609 * .build(); 610 * ApiFuture<Operation> future = regionOperationsClient.waitCallable().futureCall(request); 611 * // Do something. 612 * Operation response = future.get(); 613 * } 614 * }</pre> 615 */ waitCallable()616 public final UnaryCallable<WaitRegionOperationRequest, Operation> waitCallable() { 617 return stub.waitCallable(); 618 } 619 620 @Override close()621 public final void close() { 622 stub.close(); 623 } 624 625 @Override shutdown()626 public void shutdown() { 627 stub.shutdown(); 628 } 629 630 @Override isShutdown()631 public boolean isShutdown() { 632 return stub.isShutdown(); 633 } 634 635 @Override isTerminated()636 public boolean isTerminated() { 637 return stub.isTerminated(); 638 } 639 640 @Override shutdownNow()641 public void shutdownNow() { 642 stub.shutdownNow(); 643 } 644 645 @Override awaitTermination(long duration, TimeUnit unit)646 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 647 return stub.awaitTermination(duration, unit); 648 } 649 650 public static class ListPagedResponse 651 extends AbstractPagedListResponse< 652 ListRegionOperationsRequest, 653 OperationList, 654 Operation, 655 ListPage, 656 ListFixedSizeCollection> { 657 createAsync( PageContext<ListRegionOperationsRequest, OperationList, Operation> context, ApiFuture<OperationList> futureResponse)658 public static ApiFuture<ListPagedResponse> createAsync( 659 PageContext<ListRegionOperationsRequest, OperationList, Operation> context, 660 ApiFuture<OperationList> futureResponse) { 661 ApiFuture<ListPage> futurePage = 662 ListPage.createEmptyPage().createPageAsync(context, futureResponse); 663 return ApiFutures.transform( 664 futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor()); 665 } 666 ListPagedResponse(ListPage page)667 private ListPagedResponse(ListPage page) { 668 super(page, ListFixedSizeCollection.createEmptyCollection()); 669 } 670 } 671 672 public static class ListPage 673 extends AbstractPage<ListRegionOperationsRequest, OperationList, Operation, ListPage> { 674 ListPage( PageContext<ListRegionOperationsRequest, OperationList, Operation> context, OperationList response)675 private ListPage( 676 PageContext<ListRegionOperationsRequest, OperationList, Operation> context, 677 OperationList response) { 678 super(context, response); 679 } 680 createEmptyPage()681 private static ListPage createEmptyPage() { 682 return new ListPage(null, null); 683 } 684 685 @Override createPage( PageContext<ListRegionOperationsRequest, OperationList, Operation> context, OperationList response)686 protected ListPage createPage( 687 PageContext<ListRegionOperationsRequest, OperationList, Operation> context, 688 OperationList response) { 689 return new ListPage(context, response); 690 } 691 692 @Override createPageAsync( PageContext<ListRegionOperationsRequest, OperationList, Operation> context, ApiFuture<OperationList> futureResponse)693 public ApiFuture<ListPage> createPageAsync( 694 PageContext<ListRegionOperationsRequest, OperationList, Operation> context, 695 ApiFuture<OperationList> futureResponse) { 696 return super.createPageAsync(context, futureResponse); 697 } 698 } 699 700 public static class ListFixedSizeCollection 701 extends AbstractFixedSizeCollection< 702 ListRegionOperationsRequest, 703 OperationList, 704 Operation, 705 ListPage, 706 ListFixedSizeCollection> { 707 ListFixedSizeCollection(List<ListPage> pages, int collectionSize)708 private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) { 709 super(pages, collectionSize); 710 } 711 createEmptyCollection()712 private static ListFixedSizeCollection createEmptyCollection() { 713 return new ListFixedSizeCollection(null, 0); 714 } 715 716 @Override createCollection(List<ListPage> pages, int collectionSize)717 protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) { 718 return new ListFixedSizeCollection(pages, collectionSize); 719 } 720 } 721 } 722