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.RegionHealthChecksStub; 31 import com.google.cloud.compute.v1.stub.RegionHealthChecksStubSettings; 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 RegionHealthChecks 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 52 * String project = "project-309310695"; 53 * String region = "region-934795532"; 54 * String healthCheck = "healthCheck-1938093044"; 55 * HealthCheck response = regionHealthChecksClient.get(project, region, healthCheck); 56 * } 57 * }</pre> 58 * 59 * <p>Note: close() needs to be called on the RegionHealthChecksClient 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 RegionHealthChecksSettings 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 * RegionHealthChecksSettings regionHealthChecksSettings = 95 * RegionHealthChecksSettings.newBuilder() 96 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 97 * .build(); 98 * RegionHealthChecksClient regionHealthChecksClient = 99 * RegionHealthChecksClient.create(regionHealthChecksSettings); 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 * RegionHealthChecksSettings regionHealthChecksSettings = 111 * RegionHealthChecksSettings.newBuilder().setEndpoint(myEndpoint).build(); 112 * RegionHealthChecksClient regionHealthChecksClient = 113 * RegionHealthChecksClient.create(regionHealthChecksSettings); 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 RegionHealthChecksClient implements BackgroundResource { 120 private final RegionHealthChecksSettings settings; 121 private final RegionHealthChecksStub stub; 122 123 /** Constructs an instance of RegionHealthChecksClient with default settings. */ create()124 public static final RegionHealthChecksClient create() throws IOException { 125 return create(RegionHealthChecksSettings.newBuilder().build()); 126 } 127 128 /** 129 * Constructs an instance of RegionHealthChecksClient, 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(RegionHealthChecksSettings settings)132 public static final RegionHealthChecksClient create(RegionHealthChecksSettings settings) 133 throws IOException { 134 return new RegionHealthChecksClient(settings); 135 } 136 137 /** 138 * Constructs an instance of RegionHealthChecksClient, using the given stub for making calls. This 139 * is for advanced usage - prefer using create(RegionHealthChecksSettings). 140 */ create(RegionHealthChecksStub stub)141 public static final RegionHealthChecksClient create(RegionHealthChecksStub stub) { 142 return new RegionHealthChecksClient(stub); 143 } 144 145 /** 146 * Constructs an instance of RegionHealthChecksClient, 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 */ RegionHealthChecksClient(RegionHealthChecksSettings settings)150 protected RegionHealthChecksClient(RegionHealthChecksSettings settings) throws IOException { 151 this.settings = settings; 152 this.stub = ((RegionHealthChecksStubSettings) settings.getStubSettings()).createStub(); 153 } 154 RegionHealthChecksClient(RegionHealthChecksStub stub)155 protected RegionHealthChecksClient(RegionHealthChecksStub stub) { 156 this.settings = null; 157 this.stub = stub; 158 } 159 getSettings()160 public final RegionHealthChecksSettings getSettings() { 161 return settings; 162 } 163 getStub()164 public RegionHealthChecksStub getStub() { 165 return stub; 166 } 167 168 // AUTO-GENERATED DOCUMENTATION AND METHOD. 169 /** 170 * Deletes the specified HealthCheck resource. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 181 * String project = "project-309310695"; 182 * String region = "region-934795532"; 183 * String healthCheck = "healthCheck-1938093044"; 184 * Operation response = regionHealthChecksClient.deleteAsync(project, region, healthCheck).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 healthCheck Name of the HealthCheck resource to delete. 191 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 192 */ deleteAsync( String project, String region, String healthCheck)193 public final OperationFuture<Operation, Operation> deleteAsync( 194 String project, String region, String healthCheck) { 195 DeleteRegionHealthCheckRequest request = 196 DeleteRegionHealthCheckRequest.newBuilder() 197 .setProject(project) 198 .setRegion(region) 199 .setHealthCheck(healthCheck) 200 .build(); 201 return deleteAsync(request); 202 } 203 204 // AUTO-GENERATED DOCUMENTATION AND METHOD. 205 /** 206 * Deletes the specified HealthCheck resource. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 217 * DeleteRegionHealthCheckRequest request = 218 * DeleteRegionHealthCheckRequest.newBuilder() 219 * .setHealthCheck("healthCheck-1938093044") 220 * .setProject("project-309310695") 221 * .setRegion("region-934795532") 222 * .setRequestId("requestId693933066") 223 * .build(); 224 * Operation response = regionHealthChecksClient.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( DeleteRegionHealthCheckRequest request)233 public final OperationFuture<Operation, Operation> deleteAsync( 234 DeleteRegionHealthCheckRequest request) { 235 return deleteOperationCallable().futureCall(request); 236 } 237 238 // AUTO-GENERATED DOCUMENTATION AND METHOD. 239 /** 240 * Deletes the specified HealthCheck resource. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 251 * DeleteRegionHealthCheckRequest request = 252 * DeleteRegionHealthCheckRequest.newBuilder() 253 * .setHealthCheck("healthCheck-1938093044") 254 * .setProject("project-309310695") 255 * .setRegion("region-934795532") 256 * .setRequestId("requestId693933066") 257 * .build(); 258 * OperationFuture<Operation, Operation> future = 259 * regionHealthChecksClient.deleteOperationCallable().futureCall(request); 260 * // Do something. 261 * Operation response = future.get(); 262 * } 263 * }</pre> 264 */ 265 public final OperationCallable<DeleteRegionHealthCheckRequest, Operation, Operation> deleteOperationCallable()266 deleteOperationCallable() { 267 return stub.deleteOperationCallable(); 268 } 269 270 // AUTO-GENERATED DOCUMENTATION AND METHOD. 271 /** 272 * Deletes the specified HealthCheck resource. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 283 * DeleteRegionHealthCheckRequest request = 284 * DeleteRegionHealthCheckRequest.newBuilder() 285 * .setHealthCheck("healthCheck-1938093044") 286 * .setProject("project-309310695") 287 * .setRegion("region-934795532") 288 * .setRequestId("requestId693933066") 289 * .build(); 290 * ApiFuture<Operation> future = regionHealthChecksClient.deleteCallable().futureCall(request); 291 * // Do something. 292 * Operation response = future.get(); 293 * } 294 * }</pre> 295 */ deleteCallable()296 public final UnaryCallable<DeleteRegionHealthCheckRequest, Operation> deleteCallable() { 297 return stub.deleteCallable(); 298 } 299 300 // AUTO-GENERATED DOCUMENTATION AND METHOD. 301 /** 302 * Returns the specified HealthCheck resource. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 313 * String project = "project-309310695"; 314 * String region = "region-934795532"; 315 * String healthCheck = "healthCheck-1938093044"; 316 * HealthCheck response = regionHealthChecksClient.get(project, region, healthCheck); 317 * } 318 * }</pre> 319 * 320 * @param project Project ID for this request. 321 * @param region Name of the region scoping this request. 322 * @param healthCheck Name of the HealthCheck resource to return. 323 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 324 */ get(String project, String region, String healthCheck)325 public final HealthCheck get(String project, String region, String healthCheck) { 326 GetRegionHealthCheckRequest request = 327 GetRegionHealthCheckRequest.newBuilder() 328 .setProject(project) 329 .setRegion(region) 330 .setHealthCheck(healthCheck) 331 .build(); 332 return get(request); 333 } 334 335 // AUTO-GENERATED DOCUMENTATION AND METHOD. 336 /** 337 * Returns the specified HealthCheck resource. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 348 * GetRegionHealthCheckRequest request = 349 * GetRegionHealthCheckRequest.newBuilder() 350 * .setHealthCheck("healthCheck-1938093044") 351 * .setProject("project-309310695") 352 * .setRegion("region-934795532") 353 * .build(); 354 * HealthCheck response = regionHealthChecksClient.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(GetRegionHealthCheckRequest request)361 public final HealthCheck get(GetRegionHealthCheckRequest request) { 362 return getCallable().call(request); 363 } 364 365 // AUTO-GENERATED DOCUMENTATION AND METHOD. 366 /** 367 * Returns the specified HealthCheck resource. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 378 * GetRegionHealthCheckRequest request = 379 * GetRegionHealthCheckRequest.newBuilder() 380 * .setHealthCheck("healthCheck-1938093044") 381 * .setProject("project-309310695") 382 * .setRegion("region-934795532") 383 * .build(); 384 * ApiFuture<HealthCheck> future = regionHealthChecksClient.getCallable().futureCall(request); 385 * // Do something. 386 * HealthCheck response = future.get(); 387 * } 388 * }</pre> 389 */ getCallable()390 public final UnaryCallable<GetRegionHealthCheckRequest, HealthCheck> getCallable() { 391 return stub.getCallable(); 392 } 393 394 // AUTO-GENERATED DOCUMENTATION AND METHOD. 395 /** 396 * Creates a HealthCheck resource 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 407 * String project = "project-309310695"; 408 * String region = "region-934795532"; 409 * HealthCheck healthCheckResource = HealthCheck.newBuilder().build(); 410 * Operation response = 411 * regionHealthChecksClient.insertAsync(project, region, healthCheckResource).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 healthCheckResource 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, HealthCheck healthCheckResource)420 public final OperationFuture<Operation, Operation> insertAsync( 421 String project, String region, HealthCheck healthCheckResource) { 422 InsertRegionHealthCheckRequest request = 423 InsertRegionHealthCheckRequest.newBuilder() 424 .setProject(project) 425 .setRegion(region) 426 .setHealthCheckResource(healthCheckResource) 427 .build(); 428 return insertAsync(request); 429 } 430 431 // AUTO-GENERATED DOCUMENTATION AND METHOD. 432 /** 433 * Creates a HealthCheck resource 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 444 * InsertRegionHealthCheckRequest request = 445 * InsertRegionHealthCheckRequest.newBuilder() 446 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 447 * .setProject("project-309310695") 448 * .setRegion("region-934795532") 449 * .setRequestId("requestId693933066") 450 * .build(); 451 * Operation response = regionHealthChecksClient.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( InsertRegionHealthCheckRequest request)460 public final OperationFuture<Operation, Operation> insertAsync( 461 InsertRegionHealthCheckRequest request) { 462 return insertOperationCallable().futureCall(request); 463 } 464 465 // AUTO-GENERATED DOCUMENTATION AND METHOD. 466 /** 467 * Creates a HealthCheck resource 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 478 * InsertRegionHealthCheckRequest request = 479 * InsertRegionHealthCheckRequest.newBuilder() 480 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 481 * .setProject("project-309310695") 482 * .setRegion("region-934795532") 483 * .setRequestId("requestId693933066") 484 * .build(); 485 * OperationFuture<Operation, Operation> future = 486 * regionHealthChecksClient.insertOperationCallable().futureCall(request); 487 * // Do something. 488 * Operation response = future.get(); 489 * } 490 * }</pre> 491 */ 492 public final OperationCallable<InsertRegionHealthCheckRequest, Operation, Operation> insertOperationCallable()493 insertOperationCallable() { 494 return stub.insertOperationCallable(); 495 } 496 497 // AUTO-GENERATED DOCUMENTATION AND METHOD. 498 /** 499 * Creates a HealthCheck resource 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 510 * InsertRegionHealthCheckRequest request = 511 * InsertRegionHealthCheckRequest.newBuilder() 512 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 513 * .setProject("project-309310695") 514 * .setRegion("region-934795532") 515 * .setRequestId("requestId693933066") 516 * .build(); 517 * ApiFuture<Operation> future = regionHealthChecksClient.insertCallable().futureCall(request); 518 * // Do something. 519 * Operation response = future.get(); 520 * } 521 * }</pre> 522 */ insertCallable()523 public final UnaryCallable<InsertRegionHealthCheckRequest, Operation> insertCallable() { 524 return stub.insertCallable(); 525 } 526 527 // AUTO-GENERATED DOCUMENTATION AND METHOD. 528 /** 529 * Retrieves the list of HealthCheck resources available to the specified project. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 540 * String project = "project-309310695"; 541 * String region = "region-934795532"; 542 * for (HealthCheck element : regionHealthChecksClient.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 ListRegionHealthChecksRequest request = 554 ListRegionHealthChecksRequest.newBuilder().setProject(project).setRegion(region).build(); 555 return list(request); 556 } 557 558 // AUTO-GENERATED DOCUMENTATION AND METHOD. 559 /** 560 * Retrieves the list of HealthCheck resources available to the specified project. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 571 * ListRegionHealthChecksRequest request = 572 * ListRegionHealthChecksRequest.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 (HealthCheck element : regionHealthChecksClient.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(ListRegionHealthChecksRequest request)590 public final ListPagedResponse list(ListRegionHealthChecksRequest request) { 591 return listPagedCallable().call(request); 592 } 593 594 // AUTO-GENERATED DOCUMENTATION AND METHOD. 595 /** 596 * Retrieves the list of HealthCheck resources available to the specified project. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 607 * ListRegionHealthChecksRequest request = 608 * ListRegionHealthChecksRequest.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<HealthCheck> future = 618 * regionHealthChecksClient.listPagedCallable().futureCall(request); 619 * // Do something. 620 * for (HealthCheck element : future.get().iterateAll()) { 621 * // doThingsWith(element); 622 * } 623 * } 624 * }</pre> 625 */ listPagedCallable()626 public final UnaryCallable<ListRegionHealthChecksRequest, ListPagedResponse> listPagedCallable() { 627 return stub.listPagedCallable(); 628 } 629 630 // AUTO-GENERATED DOCUMENTATION AND METHOD. 631 /** 632 * Retrieves the list of HealthCheck resources available to the specified project. 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 643 * ListRegionHealthChecksRequest request = 644 * ListRegionHealthChecksRequest.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 * HealthCheckList response = regionHealthChecksClient.listCallable().call(request); 655 * for (HealthCheck 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<ListRegionHealthChecksRequest, HealthCheckList> listCallable() { 669 return stub.listCallable(); 670 } 671 672 // AUTO-GENERATED DOCUMENTATION AND METHOD. 673 /** 674 * Updates a HealthCheck resource in the specified project using the data included in the request. 675 * This 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 (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 686 * String project = "project-309310695"; 687 * String region = "region-934795532"; 688 * String healthCheck = "healthCheck-1938093044"; 689 * HealthCheck healthCheckResource = HealthCheck.newBuilder().build(); 690 * Operation response = 691 * regionHealthChecksClient 692 * .patchAsync(project, region, healthCheck, healthCheckResource) 693 * .get(); 694 * } 695 * }</pre> 696 * 697 * @param project Project ID for this request. 698 * @param region Name of the region scoping this request. 699 * @param healthCheck Name of the HealthCheck resource to patch. 700 * @param healthCheckResource The body resource for this request 701 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 702 */ patchAsync( String project, String region, String healthCheck, HealthCheck healthCheckResource)703 public final OperationFuture<Operation, Operation> patchAsync( 704 String project, String region, String healthCheck, HealthCheck healthCheckResource) { 705 PatchRegionHealthCheckRequest request = 706 PatchRegionHealthCheckRequest.newBuilder() 707 .setProject(project) 708 .setRegion(region) 709 .setHealthCheck(healthCheck) 710 .setHealthCheckResource(healthCheckResource) 711 .build(); 712 return patchAsync(request); 713 } 714 715 // AUTO-GENERATED DOCUMENTATION AND METHOD. 716 /** 717 * Updates a HealthCheck resource in the specified project using the data included in the request. 718 * This method supports PATCH semantics and uses the JSON merge patch format and processing rules. 719 * 720 * <p>Sample code: 721 * 722 * <pre>{@code 723 * // This snippet has been automatically generated and should be regarded as a code template only. 724 * // It will require modifications to work: 725 * // - It may require correct/in-range values for request initialization. 726 * // - It may require specifying regional endpoints when creating the service client as shown in 727 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 728 * try (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 729 * PatchRegionHealthCheckRequest request = 730 * PatchRegionHealthCheckRequest.newBuilder() 731 * .setHealthCheck("healthCheck-1938093044") 732 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 733 * .setProject("project-309310695") 734 * .setRegion("region-934795532") 735 * .setRequestId("requestId693933066") 736 * .build(); 737 * Operation response = regionHealthChecksClient.patchAsync(request).get(); 738 * } 739 * }</pre> 740 * 741 * @param request The request object containing all of the parameters for the API call. 742 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 743 */ 744 @BetaApi( 745 "The surface for long-running operations is not stable yet and may change in the future.") patchAsync( PatchRegionHealthCheckRequest request)746 public final OperationFuture<Operation, Operation> patchAsync( 747 PatchRegionHealthCheckRequest request) { 748 return patchOperationCallable().futureCall(request); 749 } 750 751 // AUTO-GENERATED DOCUMENTATION AND METHOD. 752 /** 753 * Updates a HealthCheck resource in the specified project using the data included in the request. 754 * This method supports PATCH semantics and uses the JSON merge patch format and processing rules. 755 * 756 * <p>Sample code: 757 * 758 * <pre>{@code 759 * // This snippet has been automatically generated and should be regarded as a code template only. 760 * // It will require modifications to work: 761 * // - It may require correct/in-range values for request initialization. 762 * // - It may require specifying regional endpoints when creating the service client as shown in 763 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 764 * try (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 765 * PatchRegionHealthCheckRequest request = 766 * PatchRegionHealthCheckRequest.newBuilder() 767 * .setHealthCheck("healthCheck-1938093044") 768 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 769 * .setProject("project-309310695") 770 * .setRegion("region-934795532") 771 * .setRequestId("requestId693933066") 772 * .build(); 773 * OperationFuture<Operation, Operation> future = 774 * regionHealthChecksClient.patchOperationCallable().futureCall(request); 775 * // Do something. 776 * Operation response = future.get(); 777 * } 778 * }</pre> 779 */ 780 public final OperationCallable<PatchRegionHealthCheckRequest, Operation, Operation> patchOperationCallable()781 patchOperationCallable() { 782 return stub.patchOperationCallable(); 783 } 784 785 // AUTO-GENERATED DOCUMENTATION AND METHOD. 786 /** 787 * Updates a HealthCheck resource in the specified project using the data included in the request. 788 * This method supports PATCH semantics and uses the JSON merge patch format and processing rules. 789 * 790 * <p>Sample code: 791 * 792 * <pre>{@code 793 * // This snippet has been automatically generated and should be regarded as a code template only. 794 * // It will require modifications to work: 795 * // - It may require correct/in-range values for request initialization. 796 * // - It may require specifying regional endpoints when creating the service client as shown in 797 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 798 * try (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 799 * PatchRegionHealthCheckRequest request = 800 * PatchRegionHealthCheckRequest.newBuilder() 801 * .setHealthCheck("healthCheck-1938093044") 802 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 803 * .setProject("project-309310695") 804 * .setRegion("region-934795532") 805 * .setRequestId("requestId693933066") 806 * .build(); 807 * ApiFuture<Operation> future = regionHealthChecksClient.patchCallable().futureCall(request); 808 * // Do something. 809 * Operation response = future.get(); 810 * } 811 * }</pre> 812 */ patchCallable()813 public final UnaryCallable<PatchRegionHealthCheckRequest, Operation> patchCallable() { 814 return stub.patchCallable(); 815 } 816 817 // AUTO-GENERATED DOCUMENTATION AND METHOD. 818 /** 819 * Updates a HealthCheck resource in the specified project using the data included in the request. 820 * 821 * <p>Sample code: 822 * 823 * <pre>{@code 824 * // This snippet has been automatically generated and should be regarded as a code template only. 825 * // It will require modifications to work: 826 * // - It may require correct/in-range values for request initialization. 827 * // - It may require specifying regional endpoints when creating the service client as shown in 828 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 829 * try (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 830 * String project = "project-309310695"; 831 * String region = "region-934795532"; 832 * String healthCheck = "healthCheck-1938093044"; 833 * HealthCheck healthCheckResource = HealthCheck.newBuilder().build(); 834 * Operation response = 835 * regionHealthChecksClient 836 * .updateAsync(project, region, healthCheck, healthCheckResource) 837 * .get(); 838 * } 839 * }</pre> 840 * 841 * @param project Project ID for this request. 842 * @param region Name of the region scoping this request. 843 * @param healthCheck Name of the HealthCheck resource to update. 844 * @param healthCheckResource The body resource for this request 845 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 846 */ updateAsync( String project, String region, String healthCheck, HealthCheck healthCheckResource)847 public final OperationFuture<Operation, Operation> updateAsync( 848 String project, String region, String healthCheck, HealthCheck healthCheckResource) { 849 UpdateRegionHealthCheckRequest request = 850 UpdateRegionHealthCheckRequest.newBuilder() 851 .setProject(project) 852 .setRegion(region) 853 .setHealthCheck(healthCheck) 854 .setHealthCheckResource(healthCheckResource) 855 .build(); 856 return updateAsync(request); 857 } 858 859 // AUTO-GENERATED DOCUMENTATION AND METHOD. 860 /** 861 * Updates a HealthCheck resource in the specified project using the data included in the request. 862 * 863 * <p>Sample code: 864 * 865 * <pre>{@code 866 * // This snippet has been automatically generated and should be regarded as a code template only. 867 * // It will require modifications to work: 868 * // - It may require correct/in-range values for request initialization. 869 * // - It may require specifying regional endpoints when creating the service client as shown in 870 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 871 * try (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 872 * UpdateRegionHealthCheckRequest request = 873 * UpdateRegionHealthCheckRequest.newBuilder() 874 * .setHealthCheck("healthCheck-1938093044") 875 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 876 * .setProject("project-309310695") 877 * .setRegion("region-934795532") 878 * .setRequestId("requestId693933066") 879 * .build(); 880 * Operation response = regionHealthChecksClient.updateAsync(request).get(); 881 * } 882 * }</pre> 883 * 884 * @param request The request object containing all of the parameters for the API call. 885 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 886 */ 887 @BetaApi( 888 "The surface for long-running operations is not stable yet and may change in the future.") updateAsync( UpdateRegionHealthCheckRequest request)889 public final OperationFuture<Operation, Operation> updateAsync( 890 UpdateRegionHealthCheckRequest request) { 891 return updateOperationCallable().futureCall(request); 892 } 893 894 // AUTO-GENERATED DOCUMENTATION AND METHOD. 895 /** 896 * Updates a HealthCheck resource in the specified project using the data included in the request. 897 * 898 * <p>Sample code: 899 * 900 * <pre>{@code 901 * // This snippet has been automatically generated and should be regarded as a code template only. 902 * // It will require modifications to work: 903 * // - It may require correct/in-range values for request initialization. 904 * // - It may require specifying regional endpoints when creating the service client as shown in 905 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 906 * try (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 907 * UpdateRegionHealthCheckRequest request = 908 * UpdateRegionHealthCheckRequest.newBuilder() 909 * .setHealthCheck("healthCheck-1938093044") 910 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 911 * .setProject("project-309310695") 912 * .setRegion("region-934795532") 913 * .setRequestId("requestId693933066") 914 * .build(); 915 * OperationFuture<Operation, Operation> future = 916 * regionHealthChecksClient.updateOperationCallable().futureCall(request); 917 * // Do something. 918 * Operation response = future.get(); 919 * } 920 * }</pre> 921 */ 922 public final OperationCallable<UpdateRegionHealthCheckRequest, Operation, Operation> updateOperationCallable()923 updateOperationCallable() { 924 return stub.updateOperationCallable(); 925 } 926 927 // AUTO-GENERATED DOCUMENTATION AND METHOD. 928 /** 929 * Updates a HealthCheck resource in the specified project using the data included in the request. 930 * 931 * <p>Sample code: 932 * 933 * <pre>{@code 934 * // This snippet has been automatically generated and should be regarded as a code template only. 935 * // It will require modifications to work: 936 * // - It may require correct/in-range values for request initialization. 937 * // - It may require specifying regional endpoints when creating the service client as shown in 938 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 939 * try (RegionHealthChecksClient regionHealthChecksClient = RegionHealthChecksClient.create()) { 940 * UpdateRegionHealthCheckRequest request = 941 * UpdateRegionHealthCheckRequest.newBuilder() 942 * .setHealthCheck("healthCheck-1938093044") 943 * .setHealthCheckResource(HealthCheck.newBuilder().build()) 944 * .setProject("project-309310695") 945 * .setRegion("region-934795532") 946 * .setRequestId("requestId693933066") 947 * .build(); 948 * ApiFuture<Operation> future = regionHealthChecksClient.updateCallable().futureCall(request); 949 * // Do something. 950 * Operation response = future.get(); 951 * } 952 * }</pre> 953 */ updateCallable()954 public final UnaryCallable<UpdateRegionHealthCheckRequest, Operation> updateCallable() { 955 return stub.updateCallable(); 956 } 957 958 @Override close()959 public final void close() { 960 stub.close(); 961 } 962 963 @Override shutdown()964 public void shutdown() { 965 stub.shutdown(); 966 } 967 968 @Override isShutdown()969 public boolean isShutdown() { 970 return stub.isShutdown(); 971 } 972 973 @Override isTerminated()974 public boolean isTerminated() { 975 return stub.isTerminated(); 976 } 977 978 @Override shutdownNow()979 public void shutdownNow() { 980 stub.shutdownNow(); 981 } 982 983 @Override awaitTermination(long duration, TimeUnit unit)984 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 985 return stub.awaitTermination(duration, unit); 986 } 987 988 public static class ListPagedResponse 989 extends AbstractPagedListResponse< 990 ListRegionHealthChecksRequest, 991 HealthCheckList, 992 HealthCheck, 993 ListPage, 994 ListFixedSizeCollection> { 995 createAsync( PageContext<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck> context, ApiFuture<HealthCheckList> futureResponse)996 public static ApiFuture<ListPagedResponse> createAsync( 997 PageContext<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck> context, 998 ApiFuture<HealthCheckList> futureResponse) { 999 ApiFuture<ListPage> futurePage = 1000 ListPage.createEmptyPage().createPageAsync(context, futureResponse); 1001 return ApiFutures.transform( 1002 futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor()); 1003 } 1004 ListPagedResponse(ListPage page)1005 private ListPagedResponse(ListPage page) { 1006 super(page, ListFixedSizeCollection.createEmptyCollection()); 1007 } 1008 } 1009 1010 public static class ListPage 1011 extends AbstractPage<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck, ListPage> { 1012 ListPage( PageContext<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck> context, HealthCheckList response)1013 private ListPage( 1014 PageContext<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck> context, 1015 HealthCheckList response) { 1016 super(context, response); 1017 } 1018 createEmptyPage()1019 private static ListPage createEmptyPage() { 1020 return new ListPage(null, null); 1021 } 1022 1023 @Override createPage( PageContext<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck> context, HealthCheckList response)1024 protected ListPage createPage( 1025 PageContext<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck> context, 1026 HealthCheckList response) { 1027 return new ListPage(context, response); 1028 } 1029 1030 @Override createPageAsync( PageContext<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck> context, ApiFuture<HealthCheckList> futureResponse)1031 public ApiFuture<ListPage> createPageAsync( 1032 PageContext<ListRegionHealthChecksRequest, HealthCheckList, HealthCheck> context, 1033 ApiFuture<HealthCheckList> futureResponse) { 1034 return super.createPageAsync(context, futureResponse); 1035 } 1036 } 1037 1038 public static class ListFixedSizeCollection 1039 extends AbstractFixedSizeCollection< 1040 ListRegionHealthChecksRequest, 1041 HealthCheckList, 1042 HealthCheck, 1043 ListPage, 1044 ListFixedSizeCollection> { 1045 ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1046 private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) { 1047 super(pages, collectionSize); 1048 } 1049 createEmptyCollection()1050 private static ListFixedSizeCollection createEmptyCollection() { 1051 return new ListFixedSizeCollection(null, 0); 1052 } 1053 1054 @Override createCollection(List<ListPage> pages, int collectionSize)1055 protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) { 1056 return new ListFixedSizeCollection(pages, collectionSize); 1057 } 1058 } 1059 } 1060