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.core.BetaApi; 22 import com.google.api.gax.core.BackgroundResource; 23 import com.google.api.gax.longrunning.OperationFuture; 24 import com.google.api.gax.paging.AbstractFixedSizeCollection; 25 import com.google.api.gax.paging.AbstractPage; 26 import com.google.api.gax.paging.AbstractPagedListResponse; 27 import com.google.api.gax.rpc.OperationCallable; 28 import com.google.api.gax.rpc.PageContext; 29 import com.google.api.gax.rpc.UnaryCallable; 30 import com.google.cloud.compute.v1.stub.RegionAutoscalersStub; 31 import com.google.cloud.compute.v1.stub.RegionAutoscalersStubSettings; 32 import com.google.common.util.concurrent.MoreExecutors; 33 import java.io.IOException; 34 import java.util.List; 35 import java.util.concurrent.TimeUnit; 36 import javax.annotation.Generated; 37 38 // AUTO-GENERATED DOCUMENTATION AND CLASS. 39 /** 40 * Service Description: The RegionAutoscalers API. 41 * 42 * <p>This class provides the ability to make remote calls to the backing service through method 43 * calls that map to API methods. Sample code to get started: 44 * 45 * <pre>{@code 46 * // This snippet has been automatically generated and should be regarded as a code template only. 47 * // It will require modifications to work: 48 * // - It may require correct/in-range values for request initialization. 49 * // - It may require specifying regional endpoints when creating the service client as shown in 50 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 51 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 52 * String project = "project-309310695"; 53 * String region = "region-934795532"; 54 * String autoscaler = "autoscaler517258967"; 55 * Autoscaler response = regionAutoscalersClient.get(project, region, autoscaler); 56 * } 57 * }</pre> 58 * 59 * <p>Note: close() needs to be called on the RegionAutoscalersClient object to clean up resources 60 * such as threads. In the example above, try-with-resources is used, which automatically calls 61 * close(). 62 * 63 * <p>The surface of this class includes several types of Java methods for each of the API's 64 * methods: 65 * 66 * <ol> 67 * <li>A "flattened" method. With this type of method, the fields of the request type have been 68 * converted into function parameters. It may be the case that not all fields are available as 69 * parameters, and not every API method will have a flattened method entry point. 70 * <li>A "request object" method. This type of method only takes one parameter, a request object, 71 * which must be constructed before the call. Not every API method will have a request object 72 * method. 73 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 74 * callable object, which can be used to initiate calls to the service. 75 * </ol> 76 * 77 * <p>See the individual methods for example code. 78 * 79 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 80 * these names, this class includes a format method for each type of name, and additionally a parse 81 * method to extract the individual identifiers contained within names that are returned. 82 * 83 * <p>This class can be customized by passing in a custom instance of RegionAutoscalersSettings to 84 * create(). For example: 85 * 86 * <p>To customize credentials: 87 * 88 * <pre>{@code 89 * // This snippet has been automatically generated and should be regarded as a code template only. 90 * // It will require modifications to work: 91 * // - It may require correct/in-range values for request initialization. 92 * // - It may require specifying regional endpoints when creating the service client as shown in 93 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 94 * RegionAutoscalersSettings regionAutoscalersSettings = 95 * RegionAutoscalersSettings.newBuilder() 96 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 97 * .build(); 98 * RegionAutoscalersClient regionAutoscalersClient = 99 * RegionAutoscalersClient.create(regionAutoscalersSettings); 100 * }</pre> 101 * 102 * <p>To customize the endpoint: 103 * 104 * <pre>{@code 105 * // This snippet has been automatically generated and should be regarded as a code template only. 106 * // It will require modifications to work: 107 * // - It may require correct/in-range values for request initialization. 108 * // - It may require specifying regional endpoints when creating the service client as shown in 109 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 110 * RegionAutoscalersSettings regionAutoscalersSettings = 111 * RegionAutoscalersSettings.newBuilder().setEndpoint(myEndpoint).build(); 112 * RegionAutoscalersClient regionAutoscalersClient = 113 * RegionAutoscalersClient.create(regionAutoscalersSettings); 114 * }</pre> 115 * 116 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 117 */ 118 @Generated("by gapic-generator-java") 119 public class RegionAutoscalersClient implements BackgroundResource { 120 private final RegionAutoscalersSettings settings; 121 private final RegionAutoscalersStub stub; 122 123 /** Constructs an instance of RegionAutoscalersClient with default settings. */ create()124 public static final RegionAutoscalersClient create() throws IOException { 125 return create(RegionAutoscalersSettings.newBuilder().build()); 126 } 127 128 /** 129 * Constructs an instance of RegionAutoscalersClient, using the given settings. The channels are 130 * created based on the settings passed in, or defaults for any settings that are not set. 131 */ create(RegionAutoscalersSettings settings)132 public static final RegionAutoscalersClient create(RegionAutoscalersSettings settings) 133 throws IOException { 134 return new RegionAutoscalersClient(settings); 135 } 136 137 /** 138 * Constructs an instance of RegionAutoscalersClient, using the given stub for making calls. This 139 * is for advanced usage - prefer using create(RegionAutoscalersSettings). 140 */ create(RegionAutoscalersStub stub)141 public static final RegionAutoscalersClient create(RegionAutoscalersStub stub) { 142 return new RegionAutoscalersClient(stub); 143 } 144 145 /** 146 * Constructs an instance of RegionAutoscalersClient, using the given settings. This is protected 147 * so that it is easy to make a subclass, but otherwise, the static factory methods should be 148 * preferred. 149 */ RegionAutoscalersClient(RegionAutoscalersSettings settings)150 protected RegionAutoscalersClient(RegionAutoscalersSettings settings) throws IOException { 151 this.settings = settings; 152 this.stub = ((RegionAutoscalersStubSettings) settings.getStubSettings()).createStub(); 153 } 154 RegionAutoscalersClient(RegionAutoscalersStub stub)155 protected RegionAutoscalersClient(RegionAutoscalersStub stub) { 156 this.settings = null; 157 this.stub = stub; 158 } 159 getSettings()160 public final RegionAutoscalersSettings getSettings() { 161 return settings; 162 } 163 getStub()164 public RegionAutoscalersStub getStub() { 165 return stub; 166 } 167 168 // AUTO-GENERATED DOCUMENTATION AND METHOD. 169 /** 170 * Deletes the specified autoscaler. 171 * 172 * <p>Sample code: 173 * 174 * <pre>{@code 175 * // This snippet has been automatically generated and should be regarded as a code template only. 176 * // It will require modifications to work: 177 * // - It may require correct/in-range values for request initialization. 178 * // - It may require specifying regional endpoints when creating the service client as shown in 179 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 180 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 181 * String project = "project-309310695"; 182 * String region = "region-934795532"; 183 * String autoscaler = "autoscaler517258967"; 184 * Operation response = regionAutoscalersClient.deleteAsync(project, region, autoscaler).get(); 185 * } 186 * }</pre> 187 * 188 * @param project Project ID for this request. 189 * @param region Name of the region scoping this request. 190 * @param autoscaler Name of the autoscaler to delete. 191 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 192 */ deleteAsync( String project, String region, String autoscaler)193 public final OperationFuture<Operation, Operation> deleteAsync( 194 String project, String region, String autoscaler) { 195 DeleteRegionAutoscalerRequest request = 196 DeleteRegionAutoscalerRequest.newBuilder() 197 .setProject(project) 198 .setRegion(region) 199 .setAutoscaler(autoscaler) 200 .build(); 201 return deleteAsync(request); 202 } 203 204 // AUTO-GENERATED DOCUMENTATION AND METHOD. 205 /** 206 * Deletes the specified autoscaler. 207 * 208 * <p>Sample code: 209 * 210 * <pre>{@code 211 * // This snippet has been automatically generated and should be regarded as a code template only. 212 * // It will require modifications to work: 213 * // - It may require correct/in-range values for request initialization. 214 * // - It may require specifying regional endpoints when creating the service client as shown in 215 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 216 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 217 * DeleteRegionAutoscalerRequest request = 218 * DeleteRegionAutoscalerRequest.newBuilder() 219 * .setAutoscaler("autoscaler517258967") 220 * .setProject("project-309310695") 221 * .setRegion("region-934795532") 222 * .setRequestId("requestId693933066") 223 * .build(); 224 * Operation response = regionAutoscalersClient.deleteAsync(request).get(); 225 * } 226 * }</pre> 227 * 228 * @param request The request object containing all of the parameters for the API call. 229 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 230 */ 231 @BetaApi( 232 "The surface for long-running operations is not stable yet and may change in the future.") deleteAsync( DeleteRegionAutoscalerRequest request)233 public final OperationFuture<Operation, Operation> deleteAsync( 234 DeleteRegionAutoscalerRequest request) { 235 return deleteOperationCallable().futureCall(request); 236 } 237 238 // AUTO-GENERATED DOCUMENTATION AND METHOD. 239 /** 240 * Deletes the specified autoscaler. 241 * 242 * <p>Sample code: 243 * 244 * <pre>{@code 245 * // This snippet has been automatically generated and should be regarded as a code template only. 246 * // It will require modifications to work: 247 * // - It may require correct/in-range values for request initialization. 248 * // - It may require specifying regional endpoints when creating the service client as shown in 249 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 250 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 251 * DeleteRegionAutoscalerRequest request = 252 * DeleteRegionAutoscalerRequest.newBuilder() 253 * .setAutoscaler("autoscaler517258967") 254 * .setProject("project-309310695") 255 * .setRegion("region-934795532") 256 * .setRequestId("requestId693933066") 257 * .build(); 258 * OperationFuture<Operation, Operation> future = 259 * regionAutoscalersClient.deleteOperationCallable().futureCall(request); 260 * // Do something. 261 * Operation response = future.get(); 262 * } 263 * }</pre> 264 */ 265 public final OperationCallable<DeleteRegionAutoscalerRequest, Operation, Operation> deleteOperationCallable()266 deleteOperationCallable() { 267 return stub.deleteOperationCallable(); 268 } 269 270 // AUTO-GENERATED DOCUMENTATION AND METHOD. 271 /** 272 * Deletes the specified autoscaler. 273 * 274 * <p>Sample code: 275 * 276 * <pre>{@code 277 * // This snippet has been automatically generated and should be regarded as a code template only. 278 * // It will require modifications to work: 279 * // - It may require correct/in-range values for request initialization. 280 * // - It may require specifying regional endpoints when creating the service client as shown in 281 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 282 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 283 * DeleteRegionAutoscalerRequest request = 284 * DeleteRegionAutoscalerRequest.newBuilder() 285 * .setAutoscaler("autoscaler517258967") 286 * .setProject("project-309310695") 287 * .setRegion("region-934795532") 288 * .setRequestId("requestId693933066") 289 * .build(); 290 * ApiFuture<Operation> future = regionAutoscalersClient.deleteCallable().futureCall(request); 291 * // Do something. 292 * Operation response = future.get(); 293 * } 294 * }</pre> 295 */ deleteCallable()296 public final UnaryCallable<DeleteRegionAutoscalerRequest, Operation> deleteCallable() { 297 return stub.deleteCallable(); 298 } 299 300 // AUTO-GENERATED DOCUMENTATION AND METHOD. 301 /** 302 * Returns the specified autoscaler. 303 * 304 * <p>Sample code: 305 * 306 * <pre>{@code 307 * // This snippet has been automatically generated and should be regarded as a code template only. 308 * // It will require modifications to work: 309 * // - It may require correct/in-range values for request initialization. 310 * // - It may require specifying regional endpoints when creating the service client as shown in 311 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 312 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 313 * String project = "project-309310695"; 314 * String region = "region-934795532"; 315 * String autoscaler = "autoscaler517258967"; 316 * Autoscaler response = regionAutoscalersClient.get(project, region, autoscaler); 317 * } 318 * }</pre> 319 * 320 * @param project Project ID for this request. 321 * @param region Name of the region scoping this request. 322 * @param autoscaler Name of the autoscaler to return. 323 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 324 */ get(String project, String region, String autoscaler)325 public final Autoscaler get(String project, String region, String autoscaler) { 326 GetRegionAutoscalerRequest request = 327 GetRegionAutoscalerRequest.newBuilder() 328 .setProject(project) 329 .setRegion(region) 330 .setAutoscaler(autoscaler) 331 .build(); 332 return get(request); 333 } 334 335 // AUTO-GENERATED DOCUMENTATION AND METHOD. 336 /** 337 * Returns the specified autoscaler. 338 * 339 * <p>Sample code: 340 * 341 * <pre>{@code 342 * // This snippet has been automatically generated and should be regarded as a code template only. 343 * // It will require modifications to work: 344 * // - It may require correct/in-range values for request initialization. 345 * // - It may require specifying regional endpoints when creating the service client as shown in 346 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 347 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 348 * GetRegionAutoscalerRequest request = 349 * GetRegionAutoscalerRequest.newBuilder() 350 * .setAutoscaler("autoscaler517258967") 351 * .setProject("project-309310695") 352 * .setRegion("region-934795532") 353 * .build(); 354 * Autoscaler response = regionAutoscalersClient.get(request); 355 * } 356 * }</pre> 357 * 358 * @param request The request object containing all of the parameters for the API call. 359 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 360 */ get(GetRegionAutoscalerRequest request)361 public final Autoscaler get(GetRegionAutoscalerRequest request) { 362 return getCallable().call(request); 363 } 364 365 // AUTO-GENERATED DOCUMENTATION AND METHOD. 366 /** 367 * Returns the specified autoscaler. 368 * 369 * <p>Sample code: 370 * 371 * <pre>{@code 372 * // This snippet has been automatically generated and should be regarded as a code template only. 373 * // It will require modifications to work: 374 * // - It may require correct/in-range values for request initialization. 375 * // - It may require specifying regional endpoints when creating the service client as shown in 376 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 377 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 378 * GetRegionAutoscalerRequest request = 379 * GetRegionAutoscalerRequest.newBuilder() 380 * .setAutoscaler("autoscaler517258967") 381 * .setProject("project-309310695") 382 * .setRegion("region-934795532") 383 * .build(); 384 * ApiFuture<Autoscaler> future = regionAutoscalersClient.getCallable().futureCall(request); 385 * // Do something. 386 * Autoscaler response = future.get(); 387 * } 388 * }</pre> 389 */ getCallable()390 public final UnaryCallable<GetRegionAutoscalerRequest, Autoscaler> getCallable() { 391 return stub.getCallable(); 392 } 393 394 // AUTO-GENERATED DOCUMENTATION AND METHOD. 395 /** 396 * Creates an autoscaler in the specified project using the data included in the request. 397 * 398 * <p>Sample code: 399 * 400 * <pre>{@code 401 * // This snippet has been automatically generated and should be regarded as a code template only. 402 * // It will require modifications to work: 403 * // - It may require correct/in-range values for request initialization. 404 * // - It may require specifying regional endpoints when creating the service client as shown in 405 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 406 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 407 * String project = "project-309310695"; 408 * String region = "region-934795532"; 409 * Autoscaler autoscalerResource = Autoscaler.newBuilder().build(); 410 * Operation response = 411 * regionAutoscalersClient.insertAsync(project, region, autoscalerResource).get(); 412 * } 413 * }</pre> 414 * 415 * @param project Project ID for this request. 416 * @param region Name of the region scoping this request. 417 * @param autoscalerResource The body resource for this request 418 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 419 */ insertAsync( String project, String region, Autoscaler autoscalerResource)420 public final OperationFuture<Operation, Operation> insertAsync( 421 String project, String region, Autoscaler autoscalerResource) { 422 InsertRegionAutoscalerRequest request = 423 InsertRegionAutoscalerRequest.newBuilder() 424 .setProject(project) 425 .setRegion(region) 426 .setAutoscalerResource(autoscalerResource) 427 .build(); 428 return insertAsync(request); 429 } 430 431 // AUTO-GENERATED DOCUMENTATION AND METHOD. 432 /** 433 * Creates an autoscaler in the specified project using the data included in the request. 434 * 435 * <p>Sample code: 436 * 437 * <pre>{@code 438 * // This snippet has been automatically generated and should be regarded as a code template only. 439 * // It will require modifications to work: 440 * // - It may require correct/in-range values for request initialization. 441 * // - It may require specifying regional endpoints when creating the service client as shown in 442 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 443 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 444 * InsertRegionAutoscalerRequest request = 445 * InsertRegionAutoscalerRequest.newBuilder() 446 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 447 * .setProject("project-309310695") 448 * .setRegion("region-934795532") 449 * .setRequestId("requestId693933066") 450 * .build(); 451 * Operation response = regionAutoscalersClient.insertAsync(request).get(); 452 * } 453 * }</pre> 454 * 455 * @param request The request object containing all of the parameters for the API call. 456 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 457 */ 458 @BetaApi( 459 "The surface for long-running operations is not stable yet and may change in the future.") insertAsync( InsertRegionAutoscalerRequest request)460 public final OperationFuture<Operation, Operation> insertAsync( 461 InsertRegionAutoscalerRequest request) { 462 return insertOperationCallable().futureCall(request); 463 } 464 465 // AUTO-GENERATED DOCUMENTATION AND METHOD. 466 /** 467 * Creates an autoscaler in the specified project using the data included in the request. 468 * 469 * <p>Sample code: 470 * 471 * <pre>{@code 472 * // This snippet has been automatically generated and should be regarded as a code template only. 473 * // It will require modifications to work: 474 * // - It may require correct/in-range values for request initialization. 475 * // - It may require specifying regional endpoints when creating the service client as shown in 476 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 477 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 478 * InsertRegionAutoscalerRequest request = 479 * InsertRegionAutoscalerRequest.newBuilder() 480 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 481 * .setProject("project-309310695") 482 * .setRegion("region-934795532") 483 * .setRequestId("requestId693933066") 484 * .build(); 485 * OperationFuture<Operation, Operation> future = 486 * regionAutoscalersClient.insertOperationCallable().futureCall(request); 487 * // Do something. 488 * Operation response = future.get(); 489 * } 490 * }</pre> 491 */ 492 public final OperationCallable<InsertRegionAutoscalerRequest, Operation, Operation> insertOperationCallable()493 insertOperationCallable() { 494 return stub.insertOperationCallable(); 495 } 496 497 // AUTO-GENERATED DOCUMENTATION AND METHOD. 498 /** 499 * Creates an autoscaler in the specified project using the data included in the request. 500 * 501 * <p>Sample code: 502 * 503 * <pre>{@code 504 * // This snippet has been automatically generated and should be regarded as a code template only. 505 * // It will require modifications to work: 506 * // - It may require correct/in-range values for request initialization. 507 * // - It may require specifying regional endpoints when creating the service client as shown in 508 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 509 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 510 * InsertRegionAutoscalerRequest request = 511 * InsertRegionAutoscalerRequest.newBuilder() 512 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 513 * .setProject("project-309310695") 514 * .setRegion("region-934795532") 515 * .setRequestId("requestId693933066") 516 * .build(); 517 * ApiFuture<Operation> future = regionAutoscalersClient.insertCallable().futureCall(request); 518 * // Do something. 519 * Operation response = future.get(); 520 * } 521 * }</pre> 522 */ insertCallable()523 public final UnaryCallable<InsertRegionAutoscalerRequest, Operation> insertCallable() { 524 return stub.insertCallable(); 525 } 526 527 // AUTO-GENERATED DOCUMENTATION AND METHOD. 528 /** 529 * Retrieves a list of autoscalers contained within the specified region. 530 * 531 * <p>Sample code: 532 * 533 * <pre>{@code 534 * // This snippet has been automatically generated and should be regarded as a code template only. 535 * // It will require modifications to work: 536 * // - It may require correct/in-range values for request initialization. 537 * // - It may require specifying regional endpoints when creating the service client as shown in 538 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 539 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 540 * String project = "project-309310695"; 541 * String region = "region-934795532"; 542 * for (Autoscaler element : regionAutoscalersClient.list(project, region).iterateAll()) { 543 * // doThingsWith(element); 544 * } 545 * } 546 * }</pre> 547 * 548 * @param project Project ID for this request. 549 * @param region Name of the region scoping this request. 550 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 551 */ list(String project, String region)552 public final ListPagedResponse list(String project, String region) { 553 ListRegionAutoscalersRequest request = 554 ListRegionAutoscalersRequest.newBuilder().setProject(project).setRegion(region).build(); 555 return list(request); 556 } 557 558 // AUTO-GENERATED DOCUMENTATION AND METHOD. 559 /** 560 * Retrieves a list of autoscalers contained within the specified region. 561 * 562 * <p>Sample code: 563 * 564 * <pre>{@code 565 * // This snippet has been automatically generated and should be regarded as a code template only. 566 * // It will require modifications to work: 567 * // - It may require correct/in-range values for request initialization. 568 * // - It may require specifying regional endpoints when creating the service client as shown in 569 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 570 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 571 * ListRegionAutoscalersRequest request = 572 * ListRegionAutoscalersRequest.newBuilder() 573 * .setFilter("filter-1274492040") 574 * .setMaxResults(1128457243) 575 * .setOrderBy("orderBy-1207110587") 576 * .setPageToken("pageToken873572522") 577 * .setProject("project-309310695") 578 * .setRegion("region-934795532") 579 * .setReturnPartialSuccess(true) 580 * .build(); 581 * for (Autoscaler element : regionAutoscalersClient.list(request).iterateAll()) { 582 * // doThingsWith(element); 583 * } 584 * } 585 * }</pre> 586 * 587 * @param request The request object containing all of the parameters for the API call. 588 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 589 */ list(ListRegionAutoscalersRequest request)590 public final ListPagedResponse list(ListRegionAutoscalersRequest request) { 591 return listPagedCallable().call(request); 592 } 593 594 // AUTO-GENERATED DOCUMENTATION AND METHOD. 595 /** 596 * Retrieves a list of autoscalers contained within the specified region. 597 * 598 * <p>Sample code: 599 * 600 * <pre>{@code 601 * // This snippet has been automatically generated and should be regarded as a code template only. 602 * // It will require modifications to work: 603 * // - It may require correct/in-range values for request initialization. 604 * // - It may require specifying regional endpoints when creating the service client as shown in 605 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 606 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 607 * ListRegionAutoscalersRequest request = 608 * ListRegionAutoscalersRequest.newBuilder() 609 * .setFilter("filter-1274492040") 610 * .setMaxResults(1128457243) 611 * .setOrderBy("orderBy-1207110587") 612 * .setPageToken("pageToken873572522") 613 * .setProject("project-309310695") 614 * .setRegion("region-934795532") 615 * .setReturnPartialSuccess(true) 616 * .build(); 617 * ApiFuture<Autoscaler> future = 618 * regionAutoscalersClient.listPagedCallable().futureCall(request); 619 * // Do something. 620 * for (Autoscaler element : future.get().iterateAll()) { 621 * // doThingsWith(element); 622 * } 623 * } 624 * }</pre> 625 */ listPagedCallable()626 public final UnaryCallable<ListRegionAutoscalersRequest, ListPagedResponse> listPagedCallable() { 627 return stub.listPagedCallable(); 628 } 629 630 // AUTO-GENERATED DOCUMENTATION AND METHOD. 631 /** 632 * Retrieves a list of autoscalers contained within the specified region. 633 * 634 * <p>Sample code: 635 * 636 * <pre>{@code 637 * // This snippet has been automatically generated and should be regarded as a code template only. 638 * // It will require modifications to work: 639 * // - It may require correct/in-range values for request initialization. 640 * // - It may require specifying regional endpoints when creating the service client as shown in 641 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 642 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 643 * ListRegionAutoscalersRequest request = 644 * ListRegionAutoscalersRequest.newBuilder() 645 * .setFilter("filter-1274492040") 646 * .setMaxResults(1128457243) 647 * .setOrderBy("orderBy-1207110587") 648 * .setPageToken("pageToken873572522") 649 * .setProject("project-309310695") 650 * .setRegion("region-934795532") 651 * .setReturnPartialSuccess(true) 652 * .build(); 653 * while (true) { 654 * RegionAutoscalerList response = regionAutoscalersClient.listCallable().call(request); 655 * for (Autoscaler element : response.getItemsList()) { 656 * // doThingsWith(element); 657 * } 658 * String nextPageToken = response.getNextPageToken(); 659 * if (!Strings.isNullOrEmpty(nextPageToken)) { 660 * request = request.toBuilder().setPageToken(nextPageToken).build(); 661 * } else { 662 * break; 663 * } 664 * } 665 * } 666 * }</pre> 667 */ listCallable()668 public final UnaryCallable<ListRegionAutoscalersRequest, RegionAutoscalerList> listCallable() { 669 return stub.listCallable(); 670 } 671 672 // AUTO-GENERATED DOCUMENTATION AND METHOD. 673 /** 674 * Updates an autoscaler in the specified project using the data included in the request. This 675 * method supports PATCH semantics and uses the JSON merge patch format and processing rules. 676 * 677 * <p>Sample code: 678 * 679 * <pre>{@code 680 * // This snippet has been automatically generated and should be regarded as a code template only. 681 * // It will require modifications to work: 682 * // - It may require correct/in-range values for request initialization. 683 * // - It may require specifying regional endpoints when creating the service client as shown in 684 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 685 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 686 * String project = "project-309310695"; 687 * String region = "region-934795532"; 688 * Autoscaler autoscalerResource = Autoscaler.newBuilder().build(); 689 * Operation response = 690 * regionAutoscalersClient.patchAsync(project, region, autoscalerResource).get(); 691 * } 692 * }</pre> 693 * 694 * @param project Project ID for this request. 695 * @param region Name of the region scoping this request. 696 * @param autoscalerResource The body resource for this request 697 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 698 */ patchAsync( String project, String region, Autoscaler autoscalerResource)699 public final OperationFuture<Operation, Operation> patchAsync( 700 String project, String region, Autoscaler autoscalerResource) { 701 PatchRegionAutoscalerRequest request = 702 PatchRegionAutoscalerRequest.newBuilder() 703 .setProject(project) 704 .setRegion(region) 705 .setAutoscalerResource(autoscalerResource) 706 .build(); 707 return patchAsync(request); 708 } 709 710 // AUTO-GENERATED DOCUMENTATION AND METHOD. 711 /** 712 * Updates an autoscaler in the specified project using the data included in the request. This 713 * method supports PATCH semantics and uses the JSON merge patch format and processing rules. 714 * 715 * <p>Sample code: 716 * 717 * <pre>{@code 718 * // This snippet has been automatically generated and should be regarded as a code template only. 719 * // It will require modifications to work: 720 * // - It may require correct/in-range values for request initialization. 721 * // - It may require specifying regional endpoints when creating the service client as shown in 722 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 723 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 724 * PatchRegionAutoscalerRequest request = 725 * PatchRegionAutoscalerRequest.newBuilder() 726 * .setAutoscaler("autoscaler517258967") 727 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 728 * .setProject("project-309310695") 729 * .setRegion("region-934795532") 730 * .setRequestId("requestId693933066") 731 * .build(); 732 * Operation response = regionAutoscalersClient.patchAsync(request).get(); 733 * } 734 * }</pre> 735 * 736 * @param request The request object containing all of the parameters for the API call. 737 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 738 */ 739 @BetaApi( 740 "The surface for long-running operations is not stable yet and may change in the future.") patchAsync( PatchRegionAutoscalerRequest request)741 public final OperationFuture<Operation, Operation> patchAsync( 742 PatchRegionAutoscalerRequest request) { 743 return patchOperationCallable().futureCall(request); 744 } 745 746 // AUTO-GENERATED DOCUMENTATION AND METHOD. 747 /** 748 * Updates an autoscaler in the specified project using the data included in the request. This 749 * method supports PATCH semantics and uses the JSON merge patch format and processing rules. 750 * 751 * <p>Sample code: 752 * 753 * <pre>{@code 754 * // This snippet has been automatically generated and should be regarded as a code template only. 755 * // It will require modifications to work: 756 * // - It may require correct/in-range values for request initialization. 757 * // - It may require specifying regional endpoints when creating the service client as shown in 758 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 759 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 760 * PatchRegionAutoscalerRequest request = 761 * PatchRegionAutoscalerRequest.newBuilder() 762 * .setAutoscaler("autoscaler517258967") 763 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 764 * .setProject("project-309310695") 765 * .setRegion("region-934795532") 766 * .setRequestId("requestId693933066") 767 * .build(); 768 * OperationFuture<Operation, Operation> future = 769 * regionAutoscalersClient.patchOperationCallable().futureCall(request); 770 * // Do something. 771 * Operation response = future.get(); 772 * } 773 * }</pre> 774 */ 775 public final OperationCallable<PatchRegionAutoscalerRequest, Operation, Operation> patchOperationCallable()776 patchOperationCallable() { 777 return stub.patchOperationCallable(); 778 } 779 780 // AUTO-GENERATED DOCUMENTATION AND METHOD. 781 /** 782 * Updates an autoscaler in the specified project using the data included in the request. This 783 * method supports PATCH semantics and uses the JSON merge patch format and processing rules. 784 * 785 * <p>Sample code: 786 * 787 * <pre>{@code 788 * // This snippet has been automatically generated and should be regarded as a code template only. 789 * // It will require modifications to work: 790 * // - It may require correct/in-range values for request initialization. 791 * // - It may require specifying regional endpoints when creating the service client as shown in 792 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 793 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 794 * PatchRegionAutoscalerRequest request = 795 * PatchRegionAutoscalerRequest.newBuilder() 796 * .setAutoscaler("autoscaler517258967") 797 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 798 * .setProject("project-309310695") 799 * .setRegion("region-934795532") 800 * .setRequestId("requestId693933066") 801 * .build(); 802 * ApiFuture<Operation> future = regionAutoscalersClient.patchCallable().futureCall(request); 803 * // Do something. 804 * Operation response = future.get(); 805 * } 806 * }</pre> 807 */ patchCallable()808 public final UnaryCallable<PatchRegionAutoscalerRequest, Operation> patchCallable() { 809 return stub.patchCallable(); 810 } 811 812 // AUTO-GENERATED DOCUMENTATION AND METHOD. 813 /** 814 * Updates an autoscaler in the specified project using the data included in the request. 815 * 816 * <p>Sample code: 817 * 818 * <pre>{@code 819 * // This snippet has been automatically generated and should be regarded as a code template only. 820 * // It will require modifications to work: 821 * // - It may require correct/in-range values for request initialization. 822 * // - It may require specifying regional endpoints when creating the service client as shown in 823 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 824 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 825 * String project = "project-309310695"; 826 * String region = "region-934795532"; 827 * Autoscaler autoscalerResource = Autoscaler.newBuilder().build(); 828 * Operation response = 829 * regionAutoscalersClient.updateAsync(project, region, autoscalerResource).get(); 830 * } 831 * }</pre> 832 * 833 * @param project Project ID for this request. 834 * @param region Name of the region scoping this request. 835 * @param autoscalerResource The body resource for this request 836 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 837 */ updateAsync( String project, String region, Autoscaler autoscalerResource)838 public final OperationFuture<Operation, Operation> updateAsync( 839 String project, String region, Autoscaler autoscalerResource) { 840 UpdateRegionAutoscalerRequest request = 841 UpdateRegionAutoscalerRequest.newBuilder() 842 .setProject(project) 843 .setRegion(region) 844 .setAutoscalerResource(autoscalerResource) 845 .build(); 846 return updateAsync(request); 847 } 848 849 // AUTO-GENERATED DOCUMENTATION AND METHOD. 850 /** 851 * Updates an autoscaler in the specified project using the data included in the request. 852 * 853 * <p>Sample code: 854 * 855 * <pre>{@code 856 * // This snippet has been automatically generated and should be regarded as a code template only. 857 * // It will require modifications to work: 858 * // - It may require correct/in-range values for request initialization. 859 * // - It may require specifying regional endpoints when creating the service client as shown in 860 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 861 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 862 * UpdateRegionAutoscalerRequest request = 863 * UpdateRegionAutoscalerRequest.newBuilder() 864 * .setAutoscaler("autoscaler517258967") 865 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 866 * .setProject("project-309310695") 867 * .setRegion("region-934795532") 868 * .setRequestId("requestId693933066") 869 * .build(); 870 * Operation response = regionAutoscalersClient.updateAsync(request).get(); 871 * } 872 * }</pre> 873 * 874 * @param request The request object containing all of the parameters for the API call. 875 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 876 */ 877 @BetaApi( 878 "The surface for long-running operations is not stable yet and may change in the future.") updateAsync( UpdateRegionAutoscalerRequest request)879 public final OperationFuture<Operation, Operation> updateAsync( 880 UpdateRegionAutoscalerRequest request) { 881 return updateOperationCallable().futureCall(request); 882 } 883 884 // AUTO-GENERATED DOCUMENTATION AND METHOD. 885 /** 886 * Updates an autoscaler in the specified project using the data included in the request. 887 * 888 * <p>Sample code: 889 * 890 * <pre>{@code 891 * // This snippet has been automatically generated and should be regarded as a code template only. 892 * // It will require modifications to work: 893 * // - It may require correct/in-range values for request initialization. 894 * // - It may require specifying regional endpoints when creating the service client as shown in 895 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 896 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 897 * UpdateRegionAutoscalerRequest request = 898 * UpdateRegionAutoscalerRequest.newBuilder() 899 * .setAutoscaler("autoscaler517258967") 900 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 901 * .setProject("project-309310695") 902 * .setRegion("region-934795532") 903 * .setRequestId("requestId693933066") 904 * .build(); 905 * OperationFuture<Operation, Operation> future = 906 * regionAutoscalersClient.updateOperationCallable().futureCall(request); 907 * // Do something. 908 * Operation response = future.get(); 909 * } 910 * }</pre> 911 */ 912 public final OperationCallable<UpdateRegionAutoscalerRequest, Operation, Operation> updateOperationCallable()913 updateOperationCallable() { 914 return stub.updateOperationCallable(); 915 } 916 917 // AUTO-GENERATED DOCUMENTATION AND METHOD. 918 /** 919 * Updates an autoscaler in the specified project using the data included in the request. 920 * 921 * <p>Sample code: 922 * 923 * <pre>{@code 924 * // This snippet has been automatically generated and should be regarded as a code template only. 925 * // It will require modifications to work: 926 * // - It may require correct/in-range values for request initialization. 927 * // - It may require specifying regional endpoints when creating the service client as shown in 928 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 929 * try (RegionAutoscalersClient regionAutoscalersClient = RegionAutoscalersClient.create()) { 930 * UpdateRegionAutoscalerRequest request = 931 * UpdateRegionAutoscalerRequest.newBuilder() 932 * .setAutoscaler("autoscaler517258967") 933 * .setAutoscalerResource(Autoscaler.newBuilder().build()) 934 * .setProject("project-309310695") 935 * .setRegion("region-934795532") 936 * .setRequestId("requestId693933066") 937 * .build(); 938 * ApiFuture<Operation> future = regionAutoscalersClient.updateCallable().futureCall(request); 939 * // Do something. 940 * Operation response = future.get(); 941 * } 942 * }</pre> 943 */ updateCallable()944 public final UnaryCallable<UpdateRegionAutoscalerRequest, Operation> updateCallable() { 945 return stub.updateCallable(); 946 } 947 948 @Override close()949 public final void close() { 950 stub.close(); 951 } 952 953 @Override shutdown()954 public void shutdown() { 955 stub.shutdown(); 956 } 957 958 @Override isShutdown()959 public boolean isShutdown() { 960 return stub.isShutdown(); 961 } 962 963 @Override isTerminated()964 public boolean isTerminated() { 965 return stub.isTerminated(); 966 } 967 968 @Override shutdownNow()969 public void shutdownNow() { 970 stub.shutdownNow(); 971 } 972 973 @Override awaitTermination(long duration, TimeUnit unit)974 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 975 return stub.awaitTermination(duration, unit); 976 } 977 978 public static class ListPagedResponse 979 extends AbstractPagedListResponse< 980 ListRegionAutoscalersRequest, 981 RegionAutoscalerList, 982 Autoscaler, 983 ListPage, 984 ListFixedSizeCollection> { 985 createAsync( PageContext<ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler> context, ApiFuture<RegionAutoscalerList> futureResponse)986 public static ApiFuture<ListPagedResponse> createAsync( 987 PageContext<ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler> context, 988 ApiFuture<RegionAutoscalerList> futureResponse) { 989 ApiFuture<ListPage> futurePage = 990 ListPage.createEmptyPage().createPageAsync(context, futureResponse); 991 return ApiFutures.transform( 992 futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor()); 993 } 994 ListPagedResponse(ListPage page)995 private ListPagedResponse(ListPage page) { 996 super(page, ListFixedSizeCollection.createEmptyCollection()); 997 } 998 } 999 1000 public static class ListPage 1001 extends AbstractPage< 1002 ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler, ListPage> { 1003 ListPage( PageContext<ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler> context, RegionAutoscalerList response)1004 private ListPage( 1005 PageContext<ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler> context, 1006 RegionAutoscalerList response) { 1007 super(context, response); 1008 } 1009 createEmptyPage()1010 private static ListPage createEmptyPage() { 1011 return new ListPage(null, null); 1012 } 1013 1014 @Override createPage( PageContext<ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler> context, RegionAutoscalerList response)1015 protected ListPage createPage( 1016 PageContext<ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler> context, 1017 RegionAutoscalerList response) { 1018 return new ListPage(context, response); 1019 } 1020 1021 @Override createPageAsync( PageContext<ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler> context, ApiFuture<RegionAutoscalerList> futureResponse)1022 public ApiFuture<ListPage> createPageAsync( 1023 PageContext<ListRegionAutoscalersRequest, RegionAutoscalerList, Autoscaler> context, 1024 ApiFuture<RegionAutoscalerList> futureResponse) { 1025 return super.createPageAsync(context, futureResponse); 1026 } 1027 } 1028 1029 public static class ListFixedSizeCollection 1030 extends AbstractFixedSizeCollection< 1031 ListRegionAutoscalersRequest, 1032 RegionAutoscalerList, 1033 Autoscaler, 1034 ListPage, 1035 ListFixedSizeCollection> { 1036 ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1037 private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) { 1038 super(pages, collectionSize); 1039 } 1040 createEmptyCollection()1041 private static ListFixedSizeCollection createEmptyCollection() { 1042 return new ListFixedSizeCollection(null, 0); 1043 } 1044 1045 @Override createCollection(List<ListPage> pages, int collectionSize)1046 protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) { 1047 return new ListFixedSizeCollection(pages, collectionSize); 1048 } 1049 } 1050 } 1051