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