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