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.GlobalAddressesStub; 31 import com.google.cloud.compute.v1.stub.GlobalAddressesStubSettings; 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 GlobalAddresses 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 (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 52 * String project = "project-309310695"; 53 * String address = "address-1147692044"; 54 * Address response = globalAddressesClient.get(project, address); 55 * } 56 * }</pre> 57 * 58 * <p>Note: close() needs to be called on the GlobalAddressesClient object to clean up resources 59 * such as threads. In the example above, try-with-resources is used, which automatically calls 60 * close(). 61 * 62 * <p>The surface of this class includes several types of Java methods for each of the API's 63 * methods: 64 * 65 * <ol> 66 * <li>A "flattened" method. With this type of method, the fields of the request type have been 67 * converted into function parameters. It may be the case that not all fields are available as 68 * parameters, and not every API method will have a flattened method entry point. 69 * <li>A "request object" method. This type of method only takes one parameter, a request object, 70 * which must be constructed before the call. Not every API method will have a request object 71 * method. 72 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 73 * callable object, which can be used to initiate calls to the service. 74 * </ol> 75 * 76 * <p>See the individual methods for example code. 77 * 78 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 79 * these names, this class includes a format method for each type of name, and additionally a parse 80 * method to extract the individual identifiers contained within names that are returned. 81 * 82 * <p>This class can be customized by passing in a custom instance of GlobalAddressesSettings to 83 * create(). For example: 84 * 85 * <p>To customize credentials: 86 * 87 * <pre>{@code 88 * // This snippet has been automatically generated and should be regarded as a code template only. 89 * // It will require modifications to work: 90 * // - It may require correct/in-range values for request initialization. 91 * // - It may require specifying regional endpoints when creating the service client as shown in 92 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 93 * GlobalAddressesSettings globalAddressesSettings = 94 * GlobalAddressesSettings.newBuilder() 95 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 96 * .build(); 97 * GlobalAddressesClient globalAddressesClient = 98 * GlobalAddressesClient.create(globalAddressesSettings); 99 * }</pre> 100 * 101 * <p>To customize the endpoint: 102 * 103 * <pre>{@code 104 * // This snippet has been automatically generated and should be regarded as a code template only. 105 * // It will require modifications to work: 106 * // - It may require correct/in-range values for request initialization. 107 * // - It may require specifying regional endpoints when creating the service client as shown in 108 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 109 * GlobalAddressesSettings globalAddressesSettings = 110 * GlobalAddressesSettings.newBuilder().setEndpoint(myEndpoint).build(); 111 * GlobalAddressesClient globalAddressesClient = 112 * GlobalAddressesClient.create(globalAddressesSettings); 113 * }</pre> 114 * 115 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 116 */ 117 @Generated("by gapic-generator-java") 118 public class GlobalAddressesClient implements BackgroundResource { 119 private final GlobalAddressesSettings settings; 120 private final GlobalAddressesStub stub; 121 122 /** Constructs an instance of GlobalAddressesClient with default settings. */ create()123 public static final GlobalAddressesClient create() throws IOException { 124 return create(GlobalAddressesSettings.newBuilder().build()); 125 } 126 127 /** 128 * Constructs an instance of GlobalAddressesClient, using the given settings. The channels are 129 * created based on the settings passed in, or defaults for any settings that are not set. 130 */ create(GlobalAddressesSettings settings)131 public static final GlobalAddressesClient create(GlobalAddressesSettings settings) 132 throws IOException { 133 return new GlobalAddressesClient(settings); 134 } 135 136 /** 137 * Constructs an instance of GlobalAddressesClient, using the given stub for making calls. This is 138 * for advanced usage - prefer using create(GlobalAddressesSettings). 139 */ create(GlobalAddressesStub stub)140 public static final GlobalAddressesClient create(GlobalAddressesStub stub) { 141 return new GlobalAddressesClient(stub); 142 } 143 144 /** 145 * Constructs an instance of GlobalAddressesClient, using the given settings. This is protected so 146 * that it is easy to make a subclass, but otherwise, the static factory methods should be 147 * preferred. 148 */ GlobalAddressesClient(GlobalAddressesSettings settings)149 protected GlobalAddressesClient(GlobalAddressesSettings settings) throws IOException { 150 this.settings = settings; 151 this.stub = ((GlobalAddressesStubSettings) settings.getStubSettings()).createStub(); 152 } 153 GlobalAddressesClient(GlobalAddressesStub stub)154 protected GlobalAddressesClient(GlobalAddressesStub stub) { 155 this.settings = null; 156 this.stub = stub; 157 } 158 getSettings()159 public final GlobalAddressesSettings getSettings() { 160 return settings; 161 } 162 getStub()163 public GlobalAddressesStub getStub() { 164 return stub; 165 } 166 167 // AUTO-GENERATED DOCUMENTATION AND METHOD. 168 /** 169 * Deletes the specified address resource. 170 * 171 * <p>Sample code: 172 * 173 * <pre>{@code 174 * // This snippet has been automatically generated and should be regarded as a code template only. 175 * // It will require modifications to work: 176 * // - It may require correct/in-range values for request initialization. 177 * // - It may require specifying regional endpoints when creating the service client as shown in 178 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 179 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 180 * String project = "project-309310695"; 181 * String address = "address-1147692044"; 182 * Operation response = globalAddressesClient.deleteAsync(project, address).get(); 183 * } 184 * }</pre> 185 * 186 * @param project Project ID for this request. 187 * @param address Name of the address resource to delete. 188 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 189 */ deleteAsync(String project, String address)190 public final OperationFuture<Operation, Operation> deleteAsync(String project, String address) { 191 DeleteGlobalAddressRequest request = 192 DeleteGlobalAddressRequest.newBuilder().setProject(project).setAddress(address).build(); 193 return deleteAsync(request); 194 } 195 196 // AUTO-GENERATED DOCUMENTATION AND METHOD. 197 /** 198 * Deletes the specified address resource. 199 * 200 * <p>Sample code: 201 * 202 * <pre>{@code 203 * // This snippet has been automatically generated and should be regarded as a code template only. 204 * // It will require modifications to work: 205 * // - It may require correct/in-range values for request initialization. 206 * // - It may require specifying regional endpoints when creating the service client as shown in 207 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 208 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 209 * DeleteGlobalAddressRequest request = 210 * DeleteGlobalAddressRequest.newBuilder() 211 * .setAddress("address-1147692044") 212 * .setProject("project-309310695") 213 * .setRequestId("requestId693933066") 214 * .build(); 215 * Operation response = globalAddressesClient.deleteAsync(request).get(); 216 * } 217 * }</pre> 218 * 219 * @param request The request object containing all of the parameters for the API call. 220 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 221 */ 222 @BetaApi( 223 "The surface for long-running operations is not stable yet and may change in the future.") deleteAsync( DeleteGlobalAddressRequest request)224 public final OperationFuture<Operation, Operation> deleteAsync( 225 DeleteGlobalAddressRequest request) { 226 return deleteOperationCallable().futureCall(request); 227 } 228 229 // AUTO-GENERATED DOCUMENTATION AND METHOD. 230 /** 231 * Deletes the specified address resource. 232 * 233 * <p>Sample code: 234 * 235 * <pre>{@code 236 * // This snippet has been automatically generated and should be regarded as a code template only. 237 * // It will require modifications to work: 238 * // - It may require correct/in-range values for request initialization. 239 * // - It may require specifying regional endpoints when creating the service client as shown in 240 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 241 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 242 * DeleteGlobalAddressRequest request = 243 * DeleteGlobalAddressRequest.newBuilder() 244 * .setAddress("address-1147692044") 245 * .setProject("project-309310695") 246 * .setRequestId("requestId693933066") 247 * .build(); 248 * OperationFuture<Operation, Operation> future = 249 * globalAddressesClient.deleteOperationCallable().futureCall(request); 250 * // Do something. 251 * Operation response = future.get(); 252 * } 253 * }</pre> 254 */ 255 public final OperationCallable<DeleteGlobalAddressRequest, Operation, Operation> deleteOperationCallable()256 deleteOperationCallable() { 257 return stub.deleteOperationCallable(); 258 } 259 260 // AUTO-GENERATED DOCUMENTATION AND METHOD. 261 /** 262 * Deletes the specified address resource. 263 * 264 * <p>Sample code: 265 * 266 * <pre>{@code 267 * // This snippet has been automatically generated and should be regarded as a code template only. 268 * // It will require modifications to work: 269 * // - It may require correct/in-range values for request initialization. 270 * // - It may require specifying regional endpoints when creating the service client as shown in 271 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 272 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 273 * DeleteGlobalAddressRequest request = 274 * DeleteGlobalAddressRequest.newBuilder() 275 * .setAddress("address-1147692044") 276 * .setProject("project-309310695") 277 * .setRequestId("requestId693933066") 278 * .build(); 279 * ApiFuture<Operation> future = globalAddressesClient.deleteCallable().futureCall(request); 280 * // Do something. 281 * Operation response = future.get(); 282 * } 283 * }</pre> 284 */ deleteCallable()285 public final UnaryCallable<DeleteGlobalAddressRequest, Operation> deleteCallable() { 286 return stub.deleteCallable(); 287 } 288 289 // AUTO-GENERATED DOCUMENTATION AND METHOD. 290 /** 291 * Returns the specified address resource. 292 * 293 * <p>Sample code: 294 * 295 * <pre>{@code 296 * // This snippet has been automatically generated and should be regarded as a code template only. 297 * // It will require modifications to work: 298 * // - It may require correct/in-range values for request initialization. 299 * // - It may require specifying regional endpoints when creating the service client as shown in 300 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 301 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 302 * String project = "project-309310695"; 303 * String address = "address-1147692044"; 304 * Address response = globalAddressesClient.get(project, address); 305 * } 306 * }</pre> 307 * 308 * @param project Project ID for this request. 309 * @param address Name of the address resource to return. 310 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 311 */ get(String project, String address)312 public final Address get(String project, String address) { 313 GetGlobalAddressRequest request = 314 GetGlobalAddressRequest.newBuilder().setProject(project).setAddress(address).build(); 315 return get(request); 316 } 317 318 // AUTO-GENERATED DOCUMENTATION AND METHOD. 319 /** 320 * Returns the specified address resource. 321 * 322 * <p>Sample code: 323 * 324 * <pre>{@code 325 * // This snippet has been automatically generated and should be regarded as a code template only. 326 * // It will require modifications to work: 327 * // - It may require correct/in-range values for request initialization. 328 * // - It may require specifying regional endpoints when creating the service client as shown in 329 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 330 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 331 * GetGlobalAddressRequest request = 332 * GetGlobalAddressRequest.newBuilder() 333 * .setAddress("address-1147692044") 334 * .setProject("project-309310695") 335 * .build(); 336 * Address response = globalAddressesClient.get(request); 337 * } 338 * }</pre> 339 * 340 * @param request The request object containing all of the parameters for the API call. 341 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 342 */ get(GetGlobalAddressRequest request)343 public final Address get(GetGlobalAddressRequest request) { 344 return getCallable().call(request); 345 } 346 347 // AUTO-GENERATED DOCUMENTATION AND METHOD. 348 /** 349 * Returns the specified address resource. 350 * 351 * <p>Sample code: 352 * 353 * <pre>{@code 354 * // This snippet has been automatically generated and should be regarded as a code template only. 355 * // It will require modifications to work: 356 * // - It may require correct/in-range values for request initialization. 357 * // - It may require specifying regional endpoints when creating the service client as shown in 358 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 359 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 360 * GetGlobalAddressRequest request = 361 * GetGlobalAddressRequest.newBuilder() 362 * .setAddress("address-1147692044") 363 * .setProject("project-309310695") 364 * .build(); 365 * ApiFuture<Address> future = globalAddressesClient.getCallable().futureCall(request); 366 * // Do something. 367 * Address response = future.get(); 368 * } 369 * }</pre> 370 */ getCallable()371 public final UnaryCallable<GetGlobalAddressRequest, Address> getCallable() { 372 return stub.getCallable(); 373 } 374 375 // AUTO-GENERATED DOCUMENTATION AND METHOD. 376 /** 377 * Creates an address resource in the specified project by using the data included in the request. 378 * 379 * <p>Sample code: 380 * 381 * <pre>{@code 382 * // This snippet has been automatically generated and should be regarded as a code template only. 383 * // It will require modifications to work: 384 * // - It may require correct/in-range values for request initialization. 385 * // - It may require specifying regional endpoints when creating the service client as shown in 386 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 387 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 388 * String project = "project-309310695"; 389 * Address addressResource = Address.newBuilder().build(); 390 * Operation response = globalAddressesClient.insertAsync(project, addressResource).get(); 391 * } 392 * }</pre> 393 * 394 * @param project Project ID for this request. 395 * @param addressResource The body resource for this request 396 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 397 */ insertAsync( String project, Address addressResource)398 public final OperationFuture<Operation, Operation> insertAsync( 399 String project, Address addressResource) { 400 InsertGlobalAddressRequest request = 401 InsertGlobalAddressRequest.newBuilder() 402 .setProject(project) 403 .setAddressResource(addressResource) 404 .build(); 405 return insertAsync(request); 406 } 407 408 // AUTO-GENERATED DOCUMENTATION AND METHOD. 409 /** 410 * Creates an address resource in the specified project by using the data included in the request. 411 * 412 * <p>Sample code: 413 * 414 * <pre>{@code 415 * // This snippet has been automatically generated and should be regarded as a code template only. 416 * // It will require modifications to work: 417 * // - It may require correct/in-range values for request initialization. 418 * // - It may require specifying regional endpoints when creating the service client as shown in 419 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 420 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 421 * InsertGlobalAddressRequest request = 422 * InsertGlobalAddressRequest.newBuilder() 423 * .setAddressResource(Address.newBuilder().build()) 424 * .setProject("project-309310695") 425 * .setRequestId("requestId693933066") 426 * .build(); 427 * Operation response = globalAddressesClient.insertAsync(request).get(); 428 * } 429 * }</pre> 430 * 431 * @param request The request object containing all of the parameters for the API call. 432 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 433 */ 434 @BetaApi( 435 "The surface for long-running operations is not stable yet and may change in the future.") insertAsync( InsertGlobalAddressRequest request)436 public final OperationFuture<Operation, Operation> insertAsync( 437 InsertGlobalAddressRequest request) { 438 return insertOperationCallable().futureCall(request); 439 } 440 441 // AUTO-GENERATED DOCUMENTATION AND METHOD. 442 /** 443 * Creates an address resource in the specified project by using the data included in the request. 444 * 445 * <p>Sample code: 446 * 447 * <pre>{@code 448 * // This snippet has been automatically generated and should be regarded as a code template only. 449 * // It will require modifications to work: 450 * // - It may require correct/in-range values for request initialization. 451 * // - It may require specifying regional endpoints when creating the service client as shown in 452 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 453 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 454 * InsertGlobalAddressRequest request = 455 * InsertGlobalAddressRequest.newBuilder() 456 * .setAddressResource(Address.newBuilder().build()) 457 * .setProject("project-309310695") 458 * .setRequestId("requestId693933066") 459 * .build(); 460 * OperationFuture<Operation, Operation> future = 461 * globalAddressesClient.insertOperationCallable().futureCall(request); 462 * // Do something. 463 * Operation response = future.get(); 464 * } 465 * }</pre> 466 */ 467 public final OperationCallable<InsertGlobalAddressRequest, Operation, Operation> insertOperationCallable()468 insertOperationCallable() { 469 return stub.insertOperationCallable(); 470 } 471 472 // AUTO-GENERATED DOCUMENTATION AND METHOD. 473 /** 474 * Creates an address resource in the specified project by using the data included in the request. 475 * 476 * <p>Sample code: 477 * 478 * <pre>{@code 479 * // This snippet has been automatically generated and should be regarded as a code template only. 480 * // It will require modifications to work: 481 * // - It may require correct/in-range values for request initialization. 482 * // - It may require specifying regional endpoints when creating the service client as shown in 483 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 484 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 485 * InsertGlobalAddressRequest request = 486 * InsertGlobalAddressRequest.newBuilder() 487 * .setAddressResource(Address.newBuilder().build()) 488 * .setProject("project-309310695") 489 * .setRequestId("requestId693933066") 490 * .build(); 491 * ApiFuture<Operation> future = globalAddressesClient.insertCallable().futureCall(request); 492 * // Do something. 493 * Operation response = future.get(); 494 * } 495 * }</pre> 496 */ insertCallable()497 public final UnaryCallable<InsertGlobalAddressRequest, Operation> insertCallable() { 498 return stub.insertCallable(); 499 } 500 501 // AUTO-GENERATED DOCUMENTATION AND METHOD. 502 /** 503 * Retrieves a list of global addresses. 504 * 505 * <p>Sample code: 506 * 507 * <pre>{@code 508 * // This snippet has been automatically generated and should be regarded as a code template only. 509 * // It will require modifications to work: 510 * // - It may require correct/in-range values for request initialization. 511 * // - It may require specifying regional endpoints when creating the service client as shown in 512 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 513 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 514 * String project = "project-309310695"; 515 * for (Address element : globalAddressesClient.list(project).iterateAll()) { 516 * // doThingsWith(element); 517 * } 518 * } 519 * }</pre> 520 * 521 * @param project Project ID for this request. 522 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 523 */ list(String project)524 public final ListPagedResponse list(String project) { 525 ListGlobalAddressesRequest request = 526 ListGlobalAddressesRequest.newBuilder().setProject(project).build(); 527 return list(request); 528 } 529 530 // AUTO-GENERATED DOCUMENTATION AND METHOD. 531 /** 532 * Retrieves a list of global addresses. 533 * 534 * <p>Sample code: 535 * 536 * <pre>{@code 537 * // This snippet has been automatically generated and should be regarded as a code template only. 538 * // It will require modifications to work: 539 * // - It may require correct/in-range values for request initialization. 540 * // - It may require specifying regional endpoints when creating the service client as shown in 541 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 542 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 543 * ListGlobalAddressesRequest request = 544 * ListGlobalAddressesRequest.newBuilder() 545 * .setFilter("filter-1274492040") 546 * .setMaxResults(1128457243) 547 * .setOrderBy("orderBy-1207110587") 548 * .setPageToken("pageToken873572522") 549 * .setProject("project-309310695") 550 * .setReturnPartialSuccess(true) 551 * .build(); 552 * for (Address element : globalAddressesClient.list(request).iterateAll()) { 553 * // doThingsWith(element); 554 * } 555 * } 556 * }</pre> 557 * 558 * @param request The request object containing all of the parameters for the API call. 559 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 560 */ list(ListGlobalAddressesRequest request)561 public final ListPagedResponse list(ListGlobalAddressesRequest request) { 562 return listPagedCallable().call(request); 563 } 564 565 // AUTO-GENERATED DOCUMENTATION AND METHOD. 566 /** 567 * Retrieves a list of global addresses. 568 * 569 * <p>Sample code: 570 * 571 * <pre>{@code 572 * // This snippet has been automatically generated and should be regarded as a code template only. 573 * // It will require modifications to work: 574 * // - It may require correct/in-range values for request initialization. 575 * // - It may require specifying regional endpoints when creating the service client as shown in 576 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 577 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 578 * ListGlobalAddressesRequest request = 579 * ListGlobalAddressesRequest.newBuilder() 580 * .setFilter("filter-1274492040") 581 * .setMaxResults(1128457243) 582 * .setOrderBy("orderBy-1207110587") 583 * .setPageToken("pageToken873572522") 584 * .setProject("project-309310695") 585 * .setReturnPartialSuccess(true) 586 * .build(); 587 * ApiFuture<Address> future = globalAddressesClient.listPagedCallable().futureCall(request); 588 * // Do something. 589 * for (Address element : future.get().iterateAll()) { 590 * // doThingsWith(element); 591 * } 592 * } 593 * }</pre> 594 */ listPagedCallable()595 public final UnaryCallable<ListGlobalAddressesRequest, ListPagedResponse> listPagedCallable() { 596 return stub.listPagedCallable(); 597 } 598 599 // AUTO-GENERATED DOCUMENTATION AND METHOD. 600 /** 601 * Retrieves a list of global addresses. 602 * 603 * <p>Sample code: 604 * 605 * <pre>{@code 606 * // This snippet has been automatically generated and should be regarded as a code template only. 607 * // It will require modifications to work: 608 * // - It may require correct/in-range values for request initialization. 609 * // - It may require specifying regional endpoints when creating the service client as shown in 610 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 611 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 612 * ListGlobalAddressesRequest request = 613 * ListGlobalAddressesRequest.newBuilder() 614 * .setFilter("filter-1274492040") 615 * .setMaxResults(1128457243) 616 * .setOrderBy("orderBy-1207110587") 617 * .setPageToken("pageToken873572522") 618 * .setProject("project-309310695") 619 * .setReturnPartialSuccess(true) 620 * .build(); 621 * while (true) { 622 * AddressList response = globalAddressesClient.listCallable().call(request); 623 * for (Address element : response.getItemsList()) { 624 * // doThingsWith(element); 625 * } 626 * String nextPageToken = response.getNextPageToken(); 627 * if (!Strings.isNullOrEmpty(nextPageToken)) { 628 * request = request.toBuilder().setPageToken(nextPageToken).build(); 629 * } else { 630 * break; 631 * } 632 * } 633 * } 634 * }</pre> 635 */ listCallable()636 public final UnaryCallable<ListGlobalAddressesRequest, AddressList> listCallable() { 637 return stub.listCallable(); 638 } 639 640 // AUTO-GENERATED DOCUMENTATION AND METHOD. 641 /** 642 * Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources 643 * documentation. 644 * 645 * <p>Sample code: 646 * 647 * <pre>{@code 648 * // This snippet has been automatically generated and should be regarded as a code template only. 649 * // It will require modifications to work: 650 * // - It may require correct/in-range values for request initialization. 651 * // - It may require specifying regional endpoints when creating the service client as shown in 652 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 653 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 654 * String project = "project-309310695"; 655 * String resource = "resource-341064690"; 656 * GlobalSetLabelsRequest globalSetLabelsRequestResource = 657 * GlobalSetLabelsRequest.newBuilder().build(); 658 * Operation response = 659 * globalAddressesClient 660 * .setLabelsAsync(project, resource, globalSetLabelsRequestResource) 661 * .get(); 662 * } 663 * }</pre> 664 * 665 * @param project Project ID for this request. 666 * @param resource Name or id of the resource for this request. 667 * @param globalSetLabelsRequestResource The body resource for this request 668 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 669 */ setLabelsAsync( String project, String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)670 public final OperationFuture<Operation, Operation> setLabelsAsync( 671 String project, String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource) { 672 SetLabelsGlobalAddressRequest request = 673 SetLabelsGlobalAddressRequest.newBuilder() 674 .setProject(project) 675 .setResource(resource) 676 .setGlobalSetLabelsRequestResource(globalSetLabelsRequestResource) 677 .build(); 678 return setLabelsAsync(request); 679 } 680 681 // AUTO-GENERATED DOCUMENTATION AND METHOD. 682 /** 683 * Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources 684 * documentation. 685 * 686 * <p>Sample code: 687 * 688 * <pre>{@code 689 * // This snippet has been automatically generated and should be regarded as a code template only. 690 * // It will require modifications to work: 691 * // - It may require correct/in-range values for request initialization. 692 * // - It may require specifying regional endpoints when creating the service client as shown in 693 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 694 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 695 * SetLabelsGlobalAddressRequest request = 696 * SetLabelsGlobalAddressRequest.newBuilder() 697 * .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build()) 698 * .setProject("project-309310695") 699 * .setResource("resource-341064690") 700 * .build(); 701 * Operation response = globalAddressesClient.setLabelsAsync(request).get(); 702 * } 703 * }</pre> 704 * 705 * @param request The request object containing all of the parameters for the API call. 706 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 707 */ 708 @BetaApi( 709 "The surface for long-running operations is not stable yet and may change in the future.") setLabelsAsync( SetLabelsGlobalAddressRequest request)710 public final OperationFuture<Operation, Operation> setLabelsAsync( 711 SetLabelsGlobalAddressRequest request) { 712 return setLabelsOperationCallable().futureCall(request); 713 } 714 715 // AUTO-GENERATED DOCUMENTATION AND METHOD. 716 /** 717 * Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources 718 * documentation. 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 (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 729 * SetLabelsGlobalAddressRequest request = 730 * SetLabelsGlobalAddressRequest.newBuilder() 731 * .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build()) 732 * .setProject("project-309310695") 733 * .setResource("resource-341064690") 734 * .build(); 735 * OperationFuture<Operation, Operation> future = 736 * globalAddressesClient.setLabelsOperationCallable().futureCall(request); 737 * // Do something. 738 * Operation response = future.get(); 739 * } 740 * }</pre> 741 */ 742 public final OperationCallable<SetLabelsGlobalAddressRequest, Operation, Operation> setLabelsOperationCallable()743 setLabelsOperationCallable() { 744 return stub.setLabelsOperationCallable(); 745 } 746 747 // AUTO-GENERATED DOCUMENTATION AND METHOD. 748 /** 749 * Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources 750 * documentation. 751 * 752 * <p>Sample code: 753 * 754 * <pre>{@code 755 * // This snippet has been automatically generated and should be regarded as a code template only. 756 * // It will require modifications to work: 757 * // - It may require correct/in-range values for request initialization. 758 * // - It may require specifying regional endpoints when creating the service client as shown in 759 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 760 * try (GlobalAddressesClient globalAddressesClient = GlobalAddressesClient.create()) { 761 * SetLabelsGlobalAddressRequest request = 762 * SetLabelsGlobalAddressRequest.newBuilder() 763 * .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build()) 764 * .setProject("project-309310695") 765 * .setResource("resource-341064690") 766 * .build(); 767 * ApiFuture<Operation> future = globalAddressesClient.setLabelsCallable().futureCall(request); 768 * // Do something. 769 * Operation response = future.get(); 770 * } 771 * }</pre> 772 */ setLabelsCallable()773 public final UnaryCallable<SetLabelsGlobalAddressRequest, Operation> setLabelsCallable() { 774 return stub.setLabelsCallable(); 775 } 776 777 @Override close()778 public final void close() { 779 stub.close(); 780 } 781 782 @Override shutdown()783 public void shutdown() { 784 stub.shutdown(); 785 } 786 787 @Override isShutdown()788 public boolean isShutdown() { 789 return stub.isShutdown(); 790 } 791 792 @Override isTerminated()793 public boolean isTerminated() { 794 return stub.isTerminated(); 795 } 796 797 @Override shutdownNow()798 public void shutdownNow() { 799 stub.shutdownNow(); 800 } 801 802 @Override awaitTermination(long duration, TimeUnit unit)803 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 804 return stub.awaitTermination(duration, unit); 805 } 806 807 public static class ListPagedResponse 808 extends AbstractPagedListResponse< 809 ListGlobalAddressesRequest, AddressList, Address, ListPage, ListFixedSizeCollection> { 810 createAsync( PageContext<ListGlobalAddressesRequest, AddressList, Address> context, ApiFuture<AddressList> futureResponse)811 public static ApiFuture<ListPagedResponse> createAsync( 812 PageContext<ListGlobalAddressesRequest, AddressList, Address> context, 813 ApiFuture<AddressList> futureResponse) { 814 ApiFuture<ListPage> futurePage = 815 ListPage.createEmptyPage().createPageAsync(context, futureResponse); 816 return ApiFutures.transform( 817 futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor()); 818 } 819 ListPagedResponse(ListPage page)820 private ListPagedResponse(ListPage page) { 821 super(page, ListFixedSizeCollection.createEmptyCollection()); 822 } 823 } 824 825 public static class ListPage 826 extends AbstractPage<ListGlobalAddressesRequest, AddressList, Address, ListPage> { 827 ListPage( PageContext<ListGlobalAddressesRequest, AddressList, Address> context, AddressList response)828 private ListPage( 829 PageContext<ListGlobalAddressesRequest, AddressList, Address> context, 830 AddressList response) { 831 super(context, response); 832 } 833 createEmptyPage()834 private static ListPage createEmptyPage() { 835 return new ListPage(null, null); 836 } 837 838 @Override createPage( PageContext<ListGlobalAddressesRequest, AddressList, Address> context, AddressList response)839 protected ListPage createPage( 840 PageContext<ListGlobalAddressesRequest, AddressList, Address> context, 841 AddressList response) { 842 return new ListPage(context, response); 843 } 844 845 @Override createPageAsync( PageContext<ListGlobalAddressesRequest, AddressList, Address> context, ApiFuture<AddressList> futureResponse)846 public ApiFuture<ListPage> createPageAsync( 847 PageContext<ListGlobalAddressesRequest, AddressList, Address> context, 848 ApiFuture<AddressList> futureResponse) { 849 return super.createPageAsync(context, futureResponse); 850 } 851 } 852 853 public static class ListFixedSizeCollection 854 extends AbstractFixedSizeCollection< 855 ListGlobalAddressesRequest, AddressList, Address, ListPage, ListFixedSizeCollection> { 856 ListFixedSizeCollection(List<ListPage> pages, int collectionSize)857 private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) { 858 super(pages, collectionSize); 859 } 860 createEmptyCollection()861 private static ListFixedSizeCollection createEmptyCollection() { 862 return new ListFixedSizeCollection(null, 0); 863 } 864 865 @Override createCollection(List<ListPage> pages, int collectionSize)866 protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) { 867 return new ListFixedSizeCollection(pages, collectionSize); 868 } 869 } 870 } 871