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