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.VpnGatewaysStub; 31 import com.google.cloud.compute.v1.stub.VpnGatewaysStubSettings; 32 import com.google.common.util.concurrent.MoreExecutors; 33 import java.io.IOException; 34 import java.util.List; 35 import java.util.Map; 36 import java.util.concurrent.TimeUnit; 37 import javax.annotation.Generated; 38 39 // AUTO-GENERATED DOCUMENTATION AND CLASS. 40 /** 41 * Service Description: The VpnGateways API. 42 * 43 * <p>This class provides the ability to make remote calls to the backing service through method 44 * calls that map to API methods. Sample code to get started: 45 * 46 * <pre>{@code 47 * // This snippet has been automatically generated and should be regarded as a code template only. 48 * // It will require modifications to work: 49 * // - It may require correct/in-range values for request initialization. 50 * // - It may require specifying regional endpoints when creating the service client as shown in 51 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 52 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 53 * String project = "project-309310695"; 54 * String region = "region-934795532"; 55 * String vpnGateway = "vpnGateway1920916144"; 56 * VpnGateway response = vpnGatewaysClient.get(project, region, vpnGateway); 57 * } 58 * }</pre> 59 * 60 * <p>Note: close() needs to be called on the VpnGatewaysClient object to clean up resources such as 61 * threads. In the example above, try-with-resources is used, which automatically calls close(). 62 * 63 * <p>The surface of this class includes several types of Java methods for each of the API's 64 * methods: 65 * 66 * <ol> 67 * <li>A "flattened" method. With this type of method, the fields of the request type have been 68 * converted into function parameters. It may be the case that not all fields are available as 69 * parameters, and not every API method will have a flattened method entry point. 70 * <li>A "request object" method. This type of method only takes one parameter, a request object, 71 * which must be constructed before the call. Not every API method will have a request object 72 * method. 73 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 74 * callable object, which can be used to initiate calls to the service. 75 * </ol> 76 * 77 * <p>See the individual methods for example code. 78 * 79 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 80 * these names, this class includes a format method for each type of name, and additionally a parse 81 * method to extract the individual identifiers contained within names that are returned. 82 * 83 * <p>This class can be customized by passing in a custom instance of VpnGatewaysSettings to 84 * create(). For example: 85 * 86 * <p>To customize credentials: 87 * 88 * <pre>{@code 89 * // This snippet has been automatically generated and should be regarded as a code template only. 90 * // It will require modifications to work: 91 * // - It may require correct/in-range values for request initialization. 92 * // - It may require specifying regional endpoints when creating the service client as shown in 93 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 94 * VpnGatewaysSettings vpnGatewaysSettings = 95 * VpnGatewaysSettings.newBuilder() 96 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 97 * .build(); 98 * VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create(vpnGatewaysSettings); 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 * VpnGatewaysSettings vpnGatewaysSettings = 110 * VpnGatewaysSettings.newBuilder().setEndpoint(myEndpoint).build(); 111 * VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create(vpnGatewaysSettings); 112 * }</pre> 113 * 114 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 115 */ 116 @Generated("by gapic-generator-java") 117 public class VpnGatewaysClient implements BackgroundResource { 118 private final VpnGatewaysSettings settings; 119 private final VpnGatewaysStub stub; 120 121 /** Constructs an instance of VpnGatewaysClient with default settings. */ create()122 public static final VpnGatewaysClient create() throws IOException { 123 return create(VpnGatewaysSettings.newBuilder().build()); 124 } 125 126 /** 127 * Constructs an instance of VpnGatewaysClient, using the given settings. The channels are created 128 * based on the settings passed in, or defaults for any settings that are not set. 129 */ create(VpnGatewaysSettings settings)130 public static final VpnGatewaysClient create(VpnGatewaysSettings settings) throws IOException { 131 return new VpnGatewaysClient(settings); 132 } 133 134 /** 135 * Constructs an instance of VpnGatewaysClient, using the given stub for making calls. This is for 136 * advanced usage - prefer using create(VpnGatewaysSettings). 137 */ create(VpnGatewaysStub stub)138 public static final VpnGatewaysClient create(VpnGatewaysStub stub) { 139 return new VpnGatewaysClient(stub); 140 } 141 142 /** 143 * Constructs an instance of VpnGatewaysClient, using the given settings. This is protected so 144 * that it is easy to make a subclass, but otherwise, the static factory methods should be 145 * preferred. 146 */ VpnGatewaysClient(VpnGatewaysSettings settings)147 protected VpnGatewaysClient(VpnGatewaysSettings settings) throws IOException { 148 this.settings = settings; 149 this.stub = ((VpnGatewaysStubSettings) settings.getStubSettings()).createStub(); 150 } 151 VpnGatewaysClient(VpnGatewaysStub stub)152 protected VpnGatewaysClient(VpnGatewaysStub stub) { 153 this.settings = null; 154 this.stub = stub; 155 } 156 getSettings()157 public final VpnGatewaysSettings getSettings() { 158 return settings; 159 } 160 getStub()161 public VpnGatewaysStub getStub() { 162 return stub; 163 } 164 165 // AUTO-GENERATED DOCUMENTATION AND METHOD. 166 /** 167 * Retrieves an aggregated list of VPN gateways. 168 * 169 * <p>Sample code: 170 * 171 * <pre>{@code 172 * // This snippet has been automatically generated and should be regarded as a code template only. 173 * // It will require modifications to work: 174 * // - It may require correct/in-range values for request initialization. 175 * // - It may require specifying regional endpoints when creating the service client as shown in 176 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 177 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 178 * String project = "project-309310695"; 179 * for (Map.Entry<String, VpnGatewaysScopedList> element : 180 * vpnGatewaysClient.aggregatedList(project).iterateAll()) { 181 * // doThingsWith(element); 182 * } 183 * } 184 * }</pre> 185 * 186 * @param project Project ID for this request. 187 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 188 */ aggregatedList(String project)189 public final AggregatedListPagedResponse aggregatedList(String project) { 190 AggregatedListVpnGatewaysRequest request = 191 AggregatedListVpnGatewaysRequest.newBuilder().setProject(project).build(); 192 return aggregatedList(request); 193 } 194 195 // AUTO-GENERATED DOCUMENTATION AND METHOD. 196 /** 197 * Retrieves an aggregated list of VPN gateways. 198 * 199 * <p>Sample code: 200 * 201 * <pre>{@code 202 * // This snippet has been automatically generated and should be regarded as a code template only. 203 * // It will require modifications to work: 204 * // - It may require correct/in-range values for request initialization. 205 * // - It may require specifying regional endpoints when creating the service client as shown in 206 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 207 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 208 * AggregatedListVpnGatewaysRequest request = 209 * AggregatedListVpnGatewaysRequest.newBuilder() 210 * .setFilter("filter-1274492040") 211 * .setIncludeAllScopes(true) 212 * .setMaxResults(1128457243) 213 * .setOrderBy("orderBy-1207110587") 214 * .setPageToken("pageToken873572522") 215 * .setProject("project-309310695") 216 * .setReturnPartialSuccess(true) 217 * .build(); 218 * for (Map.Entry<String, VpnGatewaysScopedList> element : 219 * vpnGatewaysClient.aggregatedList(request).iterateAll()) { 220 * // doThingsWith(element); 221 * } 222 * } 223 * }</pre> 224 * 225 * @param request The request object containing all of the parameters for the API call. 226 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 227 */ aggregatedList( AggregatedListVpnGatewaysRequest request)228 public final AggregatedListPagedResponse aggregatedList( 229 AggregatedListVpnGatewaysRequest request) { 230 return aggregatedListPagedCallable().call(request); 231 } 232 233 // AUTO-GENERATED DOCUMENTATION AND METHOD. 234 /** 235 * Retrieves an aggregated list of VPN gateways. 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 (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 246 * AggregatedListVpnGatewaysRequest request = 247 * AggregatedListVpnGatewaysRequest.newBuilder() 248 * .setFilter("filter-1274492040") 249 * .setIncludeAllScopes(true) 250 * .setMaxResults(1128457243) 251 * .setOrderBy("orderBy-1207110587") 252 * .setPageToken("pageToken873572522") 253 * .setProject("project-309310695") 254 * .setReturnPartialSuccess(true) 255 * .build(); 256 * ApiFuture<Map.Entry<String, VpnGatewaysScopedList>> future = 257 * vpnGatewaysClient.aggregatedListPagedCallable().futureCall(request); 258 * // Do something. 259 * for (Map.Entry<String, VpnGatewaysScopedList> element : future.get().iterateAll()) { 260 * // doThingsWith(element); 261 * } 262 * } 263 * }</pre> 264 */ 265 public final UnaryCallable<AggregatedListVpnGatewaysRequest, AggregatedListPagedResponse> aggregatedListPagedCallable()266 aggregatedListPagedCallable() { 267 return stub.aggregatedListPagedCallable(); 268 } 269 270 // AUTO-GENERATED DOCUMENTATION AND METHOD. 271 /** 272 * Retrieves an aggregated list of VPN gateways. 273 * 274 * <p>Sample code: 275 * 276 * <pre>{@code 277 * // This snippet has been automatically generated and should be regarded as a code template only. 278 * // It will require modifications to work: 279 * // - It may require correct/in-range values for request initialization. 280 * // - It may require specifying regional endpoints when creating the service client as shown in 281 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 282 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 283 * AggregatedListVpnGatewaysRequest request = 284 * AggregatedListVpnGatewaysRequest.newBuilder() 285 * .setFilter("filter-1274492040") 286 * .setIncludeAllScopes(true) 287 * .setMaxResults(1128457243) 288 * .setOrderBy("orderBy-1207110587") 289 * .setPageToken("pageToken873572522") 290 * .setProject("project-309310695") 291 * .setReturnPartialSuccess(true) 292 * .build(); 293 * while (true) { 294 * VpnGatewayAggregatedList response = 295 * vpnGatewaysClient.aggregatedListCallable().call(request); 296 * for (Map.Entry<String, VpnGatewaysScopedList> element : response.getItemsList()) { 297 * // doThingsWith(element); 298 * } 299 * String nextPageToken = response.getNextPageToken(); 300 * if (!Strings.isNullOrEmpty(nextPageToken)) { 301 * request = request.toBuilder().setPageToken(nextPageToken).build(); 302 * } else { 303 * break; 304 * } 305 * } 306 * } 307 * }</pre> 308 */ 309 public final UnaryCallable<AggregatedListVpnGatewaysRequest, VpnGatewayAggregatedList> aggregatedListCallable()310 aggregatedListCallable() { 311 return stub.aggregatedListCallable(); 312 } 313 314 // AUTO-GENERATED DOCUMENTATION AND METHOD. 315 /** 316 * Deletes the specified VPN gateway. 317 * 318 * <p>Sample code: 319 * 320 * <pre>{@code 321 * // This snippet has been automatically generated and should be regarded as a code template only. 322 * // It will require modifications to work: 323 * // - It may require correct/in-range values for request initialization. 324 * // - It may require specifying regional endpoints when creating the service client as shown in 325 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 326 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 327 * String project = "project-309310695"; 328 * String region = "region-934795532"; 329 * String vpnGateway = "vpnGateway1920916144"; 330 * Operation response = vpnGatewaysClient.deleteAsync(project, region, vpnGateway).get(); 331 * } 332 * }</pre> 333 * 334 * @param project Project ID for this request. 335 * @param region Name of the region for this request. 336 * @param vpnGateway Name of the VPN gateway to delete. 337 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 338 */ deleteAsync( String project, String region, String vpnGateway)339 public final OperationFuture<Operation, Operation> deleteAsync( 340 String project, String region, String vpnGateway) { 341 DeleteVpnGatewayRequest request = 342 DeleteVpnGatewayRequest.newBuilder() 343 .setProject(project) 344 .setRegion(region) 345 .setVpnGateway(vpnGateway) 346 .build(); 347 return deleteAsync(request); 348 } 349 350 // AUTO-GENERATED DOCUMENTATION AND METHOD. 351 /** 352 * Deletes the specified VPN gateway. 353 * 354 * <p>Sample code: 355 * 356 * <pre>{@code 357 * // This snippet has been automatically generated and should be regarded as a code template only. 358 * // It will require modifications to work: 359 * // - It may require correct/in-range values for request initialization. 360 * // - It may require specifying regional endpoints when creating the service client as shown in 361 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 362 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 363 * DeleteVpnGatewayRequest request = 364 * DeleteVpnGatewayRequest.newBuilder() 365 * .setProject("project-309310695") 366 * .setRegion("region-934795532") 367 * .setRequestId("requestId693933066") 368 * .setVpnGateway("vpnGateway1920916144") 369 * .build(); 370 * Operation response = vpnGatewaysClient.deleteAsync(request).get(); 371 * } 372 * }</pre> 373 * 374 * @param request The request object containing all of the parameters for the API call. 375 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 376 */ 377 @BetaApi( 378 "The surface for long-running operations is not stable yet and may change in the future.") deleteAsync(DeleteVpnGatewayRequest request)379 public final OperationFuture<Operation, Operation> deleteAsync(DeleteVpnGatewayRequest request) { 380 return deleteOperationCallable().futureCall(request); 381 } 382 383 // AUTO-GENERATED DOCUMENTATION AND METHOD. 384 /** 385 * Deletes the specified VPN gateway. 386 * 387 * <p>Sample code: 388 * 389 * <pre>{@code 390 * // This snippet has been automatically generated and should be regarded as a code template only. 391 * // It will require modifications to work: 392 * // - It may require correct/in-range values for request initialization. 393 * // - It may require specifying regional endpoints when creating the service client as shown in 394 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 395 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 396 * DeleteVpnGatewayRequest request = 397 * DeleteVpnGatewayRequest.newBuilder() 398 * .setProject("project-309310695") 399 * .setRegion("region-934795532") 400 * .setRequestId("requestId693933066") 401 * .setVpnGateway("vpnGateway1920916144") 402 * .build(); 403 * OperationFuture<Operation, Operation> future = 404 * vpnGatewaysClient.deleteOperationCallable().futureCall(request); 405 * // Do something. 406 * Operation response = future.get(); 407 * } 408 * }</pre> 409 */ 410 public final OperationCallable<DeleteVpnGatewayRequest, Operation, Operation> deleteOperationCallable()411 deleteOperationCallable() { 412 return stub.deleteOperationCallable(); 413 } 414 415 // AUTO-GENERATED DOCUMENTATION AND METHOD. 416 /** 417 * Deletes the specified VPN gateway. 418 * 419 * <p>Sample code: 420 * 421 * <pre>{@code 422 * // This snippet has been automatically generated and should be regarded as a code template only. 423 * // It will require modifications to work: 424 * // - It may require correct/in-range values for request initialization. 425 * // - It may require specifying regional endpoints when creating the service client as shown in 426 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 427 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 428 * DeleteVpnGatewayRequest request = 429 * DeleteVpnGatewayRequest.newBuilder() 430 * .setProject("project-309310695") 431 * .setRegion("region-934795532") 432 * .setRequestId("requestId693933066") 433 * .setVpnGateway("vpnGateway1920916144") 434 * .build(); 435 * ApiFuture<Operation> future = vpnGatewaysClient.deleteCallable().futureCall(request); 436 * // Do something. 437 * Operation response = future.get(); 438 * } 439 * }</pre> 440 */ deleteCallable()441 public final UnaryCallable<DeleteVpnGatewayRequest, Operation> deleteCallable() { 442 return stub.deleteCallable(); 443 } 444 445 // AUTO-GENERATED DOCUMENTATION AND METHOD. 446 /** 447 * Returns the specified VPN gateway. 448 * 449 * <p>Sample code: 450 * 451 * <pre>{@code 452 * // This snippet has been automatically generated and should be regarded as a code template only. 453 * // It will require modifications to work: 454 * // - It may require correct/in-range values for request initialization. 455 * // - It may require specifying regional endpoints when creating the service client as shown in 456 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 457 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 458 * String project = "project-309310695"; 459 * String region = "region-934795532"; 460 * String vpnGateway = "vpnGateway1920916144"; 461 * VpnGateway response = vpnGatewaysClient.get(project, region, vpnGateway); 462 * } 463 * }</pre> 464 * 465 * @param project Project ID for this request. 466 * @param region Name of the region for this request. 467 * @param vpnGateway Name of the VPN gateway to return. 468 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 469 */ get(String project, String region, String vpnGateway)470 public final VpnGateway get(String project, String region, String vpnGateway) { 471 GetVpnGatewayRequest request = 472 GetVpnGatewayRequest.newBuilder() 473 .setProject(project) 474 .setRegion(region) 475 .setVpnGateway(vpnGateway) 476 .build(); 477 return get(request); 478 } 479 480 // AUTO-GENERATED DOCUMENTATION AND METHOD. 481 /** 482 * Returns the specified VPN gateway. 483 * 484 * <p>Sample code: 485 * 486 * <pre>{@code 487 * // This snippet has been automatically generated and should be regarded as a code template only. 488 * // It will require modifications to work: 489 * // - It may require correct/in-range values for request initialization. 490 * // - It may require specifying regional endpoints when creating the service client as shown in 491 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 492 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 493 * GetVpnGatewayRequest request = 494 * GetVpnGatewayRequest.newBuilder() 495 * .setProject("project-309310695") 496 * .setRegion("region-934795532") 497 * .setVpnGateway("vpnGateway1920916144") 498 * .build(); 499 * VpnGateway response = vpnGatewaysClient.get(request); 500 * } 501 * }</pre> 502 * 503 * @param request The request object containing all of the parameters for the API call. 504 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 505 */ get(GetVpnGatewayRequest request)506 public final VpnGateway get(GetVpnGatewayRequest request) { 507 return getCallable().call(request); 508 } 509 510 // AUTO-GENERATED DOCUMENTATION AND METHOD. 511 /** 512 * Returns the specified VPN gateway. 513 * 514 * <p>Sample code: 515 * 516 * <pre>{@code 517 * // This snippet has been automatically generated and should be regarded as a code template only. 518 * // It will require modifications to work: 519 * // - It may require correct/in-range values for request initialization. 520 * // - It may require specifying regional endpoints when creating the service client as shown in 521 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 522 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 523 * GetVpnGatewayRequest request = 524 * GetVpnGatewayRequest.newBuilder() 525 * .setProject("project-309310695") 526 * .setRegion("region-934795532") 527 * .setVpnGateway("vpnGateway1920916144") 528 * .build(); 529 * ApiFuture<VpnGateway> future = vpnGatewaysClient.getCallable().futureCall(request); 530 * // Do something. 531 * VpnGateway response = future.get(); 532 * } 533 * }</pre> 534 */ getCallable()535 public final UnaryCallable<GetVpnGatewayRequest, VpnGateway> getCallable() { 536 return stub.getCallable(); 537 } 538 539 // AUTO-GENERATED DOCUMENTATION AND METHOD. 540 /** 541 * Returns the status for the specified VPN gateway. 542 * 543 * <p>Sample code: 544 * 545 * <pre>{@code 546 * // This snippet has been automatically generated and should be regarded as a code template only. 547 * // It will require modifications to work: 548 * // - It may require correct/in-range values for request initialization. 549 * // - It may require specifying regional endpoints when creating the service client as shown in 550 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 551 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 552 * String project = "project-309310695"; 553 * String region = "region-934795532"; 554 * String vpnGateway = "vpnGateway1920916144"; 555 * VpnGatewaysGetStatusResponse response = 556 * vpnGatewaysClient.getStatus(project, region, vpnGateway); 557 * } 558 * }</pre> 559 * 560 * @param project Project ID for this request. 561 * @param region Name of the region for this request. 562 * @param vpnGateway Name of the VPN gateway to return. 563 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 564 */ getStatus( String project, String region, String vpnGateway)565 public final VpnGatewaysGetStatusResponse getStatus( 566 String project, String region, String vpnGateway) { 567 GetStatusVpnGatewayRequest request = 568 GetStatusVpnGatewayRequest.newBuilder() 569 .setProject(project) 570 .setRegion(region) 571 .setVpnGateway(vpnGateway) 572 .build(); 573 return getStatus(request); 574 } 575 576 // AUTO-GENERATED DOCUMENTATION AND METHOD. 577 /** 578 * Returns the status for the specified VPN gateway. 579 * 580 * <p>Sample code: 581 * 582 * <pre>{@code 583 * // This snippet has been automatically generated and should be regarded as a code template only. 584 * // It will require modifications to work: 585 * // - It may require correct/in-range values for request initialization. 586 * // - It may require specifying regional endpoints when creating the service client as shown in 587 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 588 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 589 * GetStatusVpnGatewayRequest request = 590 * GetStatusVpnGatewayRequest.newBuilder() 591 * .setProject("project-309310695") 592 * .setRegion("region-934795532") 593 * .setVpnGateway("vpnGateway1920916144") 594 * .build(); 595 * VpnGatewaysGetStatusResponse response = vpnGatewaysClient.getStatus(request); 596 * } 597 * }</pre> 598 * 599 * @param request The request object containing all of the parameters for the API call. 600 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 601 */ getStatus(GetStatusVpnGatewayRequest request)602 public final VpnGatewaysGetStatusResponse getStatus(GetStatusVpnGatewayRequest request) { 603 return getStatusCallable().call(request); 604 } 605 606 // AUTO-GENERATED DOCUMENTATION AND METHOD. 607 /** 608 * Returns the status for the specified VPN gateway. 609 * 610 * <p>Sample code: 611 * 612 * <pre>{@code 613 * // This snippet has been automatically generated and should be regarded as a code template only. 614 * // It will require modifications to work: 615 * // - It may require correct/in-range values for request initialization. 616 * // - It may require specifying regional endpoints when creating the service client as shown in 617 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 618 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 619 * GetStatusVpnGatewayRequest request = 620 * GetStatusVpnGatewayRequest.newBuilder() 621 * .setProject("project-309310695") 622 * .setRegion("region-934795532") 623 * .setVpnGateway("vpnGateway1920916144") 624 * .build(); 625 * ApiFuture<VpnGatewaysGetStatusResponse> future = 626 * vpnGatewaysClient.getStatusCallable().futureCall(request); 627 * // Do something. 628 * VpnGatewaysGetStatusResponse response = future.get(); 629 * } 630 * }</pre> 631 */ 632 public final UnaryCallable<GetStatusVpnGatewayRequest, VpnGatewaysGetStatusResponse> getStatusCallable()633 getStatusCallable() { 634 return stub.getStatusCallable(); 635 } 636 637 // AUTO-GENERATED DOCUMENTATION AND METHOD. 638 /** 639 * Creates a VPN gateway in the specified project and region using the data included in the 640 * request. 641 * 642 * <p>Sample code: 643 * 644 * <pre>{@code 645 * // This snippet has been automatically generated and should be regarded as a code template only. 646 * // It will require modifications to work: 647 * // - It may require correct/in-range values for request initialization. 648 * // - It may require specifying regional endpoints when creating the service client as shown in 649 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 650 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 651 * String project = "project-309310695"; 652 * String region = "region-934795532"; 653 * VpnGateway vpnGatewayResource = VpnGateway.newBuilder().build(); 654 * Operation response = vpnGatewaysClient.insertAsync(project, region, vpnGatewayResource).get(); 655 * } 656 * }</pre> 657 * 658 * @param project Project ID for this request. 659 * @param region Name of the region for this request. 660 * @param vpnGatewayResource The body resource for this request 661 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 662 */ insertAsync( String project, String region, VpnGateway vpnGatewayResource)663 public final OperationFuture<Operation, Operation> insertAsync( 664 String project, String region, VpnGateway vpnGatewayResource) { 665 InsertVpnGatewayRequest request = 666 InsertVpnGatewayRequest.newBuilder() 667 .setProject(project) 668 .setRegion(region) 669 .setVpnGatewayResource(vpnGatewayResource) 670 .build(); 671 return insertAsync(request); 672 } 673 674 // AUTO-GENERATED DOCUMENTATION AND METHOD. 675 /** 676 * Creates a VPN gateway in the specified project and region using the data included in the 677 * request. 678 * 679 * <p>Sample code: 680 * 681 * <pre>{@code 682 * // This snippet has been automatically generated and should be regarded as a code template only. 683 * // It will require modifications to work: 684 * // - It may require correct/in-range values for request initialization. 685 * // - It may require specifying regional endpoints when creating the service client as shown in 686 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 687 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 688 * InsertVpnGatewayRequest request = 689 * InsertVpnGatewayRequest.newBuilder() 690 * .setProject("project-309310695") 691 * .setRegion("region-934795532") 692 * .setRequestId("requestId693933066") 693 * .setVpnGatewayResource(VpnGateway.newBuilder().build()) 694 * .build(); 695 * Operation response = vpnGatewaysClient.insertAsync(request).get(); 696 * } 697 * }</pre> 698 * 699 * @param request The request object containing all of the parameters for the API call. 700 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 701 */ 702 @BetaApi( 703 "The surface for long-running operations is not stable yet and may change in the future.") insertAsync(InsertVpnGatewayRequest request)704 public final OperationFuture<Operation, Operation> insertAsync(InsertVpnGatewayRequest request) { 705 return insertOperationCallable().futureCall(request); 706 } 707 708 // AUTO-GENERATED DOCUMENTATION AND METHOD. 709 /** 710 * Creates a VPN gateway in the specified project and region using the data included in the 711 * request. 712 * 713 * <p>Sample code: 714 * 715 * <pre>{@code 716 * // This snippet has been automatically generated and should be regarded as a code template only. 717 * // It will require modifications to work: 718 * // - It may require correct/in-range values for request initialization. 719 * // - It may require specifying regional endpoints when creating the service client as shown in 720 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 721 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 722 * InsertVpnGatewayRequest request = 723 * InsertVpnGatewayRequest.newBuilder() 724 * .setProject("project-309310695") 725 * .setRegion("region-934795532") 726 * .setRequestId("requestId693933066") 727 * .setVpnGatewayResource(VpnGateway.newBuilder().build()) 728 * .build(); 729 * OperationFuture<Operation, Operation> future = 730 * vpnGatewaysClient.insertOperationCallable().futureCall(request); 731 * // Do something. 732 * Operation response = future.get(); 733 * } 734 * }</pre> 735 */ 736 public final OperationCallable<InsertVpnGatewayRequest, Operation, Operation> insertOperationCallable()737 insertOperationCallable() { 738 return stub.insertOperationCallable(); 739 } 740 741 // AUTO-GENERATED DOCUMENTATION AND METHOD. 742 /** 743 * Creates a VPN gateway in the specified project and region using the data included in the 744 * request. 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 (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 755 * InsertVpnGatewayRequest request = 756 * InsertVpnGatewayRequest.newBuilder() 757 * .setProject("project-309310695") 758 * .setRegion("region-934795532") 759 * .setRequestId("requestId693933066") 760 * .setVpnGatewayResource(VpnGateway.newBuilder().build()) 761 * .build(); 762 * ApiFuture<Operation> future = vpnGatewaysClient.insertCallable().futureCall(request); 763 * // Do something. 764 * Operation response = future.get(); 765 * } 766 * }</pre> 767 */ insertCallable()768 public final UnaryCallable<InsertVpnGatewayRequest, Operation> insertCallable() { 769 return stub.insertCallable(); 770 } 771 772 // AUTO-GENERATED DOCUMENTATION AND METHOD. 773 /** 774 * Retrieves a list of VPN gateways available to the specified project and region. 775 * 776 * <p>Sample code: 777 * 778 * <pre>{@code 779 * // This snippet has been automatically generated and should be regarded as a code template only. 780 * // It will require modifications to work: 781 * // - It may require correct/in-range values for request initialization. 782 * // - It may require specifying regional endpoints when creating the service client as shown in 783 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 784 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 785 * String project = "project-309310695"; 786 * String region = "region-934795532"; 787 * for (VpnGateway element : vpnGatewaysClient.list(project, region).iterateAll()) { 788 * // doThingsWith(element); 789 * } 790 * } 791 * }</pre> 792 * 793 * @param project Project ID for this request. 794 * @param region Name of the region for this request. 795 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 796 */ list(String project, String region)797 public final ListPagedResponse list(String project, String region) { 798 ListVpnGatewaysRequest request = 799 ListVpnGatewaysRequest.newBuilder().setProject(project).setRegion(region).build(); 800 return list(request); 801 } 802 803 // AUTO-GENERATED DOCUMENTATION AND METHOD. 804 /** 805 * Retrieves a list of VPN gateways available to the specified project and region. 806 * 807 * <p>Sample code: 808 * 809 * <pre>{@code 810 * // This snippet has been automatically generated and should be regarded as a code template only. 811 * // It will require modifications to work: 812 * // - It may require correct/in-range values for request initialization. 813 * // - It may require specifying regional endpoints when creating the service client as shown in 814 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 815 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 816 * ListVpnGatewaysRequest request = 817 * ListVpnGatewaysRequest.newBuilder() 818 * .setFilter("filter-1274492040") 819 * .setMaxResults(1128457243) 820 * .setOrderBy("orderBy-1207110587") 821 * .setPageToken("pageToken873572522") 822 * .setProject("project-309310695") 823 * .setRegion("region-934795532") 824 * .setReturnPartialSuccess(true) 825 * .build(); 826 * for (VpnGateway element : vpnGatewaysClient.list(request).iterateAll()) { 827 * // doThingsWith(element); 828 * } 829 * } 830 * }</pre> 831 * 832 * @param request The request object containing all of the parameters for the API call. 833 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 834 */ list(ListVpnGatewaysRequest request)835 public final ListPagedResponse list(ListVpnGatewaysRequest request) { 836 return listPagedCallable().call(request); 837 } 838 839 // AUTO-GENERATED DOCUMENTATION AND METHOD. 840 /** 841 * Retrieves a list of VPN gateways available to the specified project and region. 842 * 843 * <p>Sample code: 844 * 845 * <pre>{@code 846 * // This snippet has been automatically generated and should be regarded as a code template only. 847 * // It will require modifications to work: 848 * // - It may require correct/in-range values for request initialization. 849 * // - It may require specifying regional endpoints when creating the service client as shown in 850 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 851 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 852 * ListVpnGatewaysRequest request = 853 * ListVpnGatewaysRequest.newBuilder() 854 * .setFilter("filter-1274492040") 855 * .setMaxResults(1128457243) 856 * .setOrderBy("orderBy-1207110587") 857 * .setPageToken("pageToken873572522") 858 * .setProject("project-309310695") 859 * .setRegion("region-934795532") 860 * .setReturnPartialSuccess(true) 861 * .build(); 862 * ApiFuture<VpnGateway> future = vpnGatewaysClient.listPagedCallable().futureCall(request); 863 * // Do something. 864 * for (VpnGateway element : future.get().iterateAll()) { 865 * // doThingsWith(element); 866 * } 867 * } 868 * }</pre> 869 */ listPagedCallable()870 public final UnaryCallable<ListVpnGatewaysRequest, ListPagedResponse> listPagedCallable() { 871 return stub.listPagedCallable(); 872 } 873 874 // AUTO-GENERATED DOCUMENTATION AND METHOD. 875 /** 876 * Retrieves a list of VPN gateways available to the specified project and region. 877 * 878 * <p>Sample code: 879 * 880 * <pre>{@code 881 * // This snippet has been automatically generated and should be regarded as a code template only. 882 * // It will require modifications to work: 883 * // - It may require correct/in-range values for request initialization. 884 * // - It may require specifying regional endpoints when creating the service client as shown in 885 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 886 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 887 * ListVpnGatewaysRequest request = 888 * ListVpnGatewaysRequest.newBuilder() 889 * .setFilter("filter-1274492040") 890 * .setMaxResults(1128457243) 891 * .setOrderBy("orderBy-1207110587") 892 * .setPageToken("pageToken873572522") 893 * .setProject("project-309310695") 894 * .setRegion("region-934795532") 895 * .setReturnPartialSuccess(true) 896 * .build(); 897 * while (true) { 898 * VpnGatewayList response = vpnGatewaysClient.listCallable().call(request); 899 * for (VpnGateway element : response.getItemsList()) { 900 * // doThingsWith(element); 901 * } 902 * String nextPageToken = response.getNextPageToken(); 903 * if (!Strings.isNullOrEmpty(nextPageToken)) { 904 * request = request.toBuilder().setPageToken(nextPageToken).build(); 905 * } else { 906 * break; 907 * } 908 * } 909 * } 910 * }</pre> 911 */ listCallable()912 public final UnaryCallable<ListVpnGatewaysRequest, VpnGatewayList> listCallable() { 913 return stub.listCallable(); 914 } 915 916 // AUTO-GENERATED DOCUMENTATION AND METHOD. 917 /** 918 * Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources 919 * documentation. 920 * 921 * <p>Sample code: 922 * 923 * <pre>{@code 924 * // This snippet has been automatically generated and should be regarded as a code template only. 925 * // It will require modifications to work: 926 * // - It may require correct/in-range values for request initialization. 927 * // - It may require specifying regional endpoints when creating the service client as shown in 928 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 929 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 930 * String project = "project-309310695"; 931 * String region = "region-934795532"; 932 * String resource = "resource-341064690"; 933 * RegionSetLabelsRequest regionSetLabelsRequestResource = 934 * RegionSetLabelsRequest.newBuilder().build(); 935 * Operation response = 936 * vpnGatewaysClient 937 * .setLabelsAsync(project, region, resource, regionSetLabelsRequestResource) 938 * .get(); 939 * } 940 * }</pre> 941 * 942 * @param project Project ID for this request. 943 * @param region The region for this request. 944 * @param resource Name or id of the resource for this request. 945 * @param regionSetLabelsRequestResource The body resource for this request 946 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 947 */ setLabelsAsync( String project, String region, String resource, RegionSetLabelsRequest regionSetLabelsRequestResource)948 public final OperationFuture<Operation, Operation> setLabelsAsync( 949 String project, 950 String region, 951 String resource, 952 RegionSetLabelsRequest regionSetLabelsRequestResource) { 953 SetLabelsVpnGatewayRequest request = 954 SetLabelsVpnGatewayRequest.newBuilder() 955 .setProject(project) 956 .setRegion(region) 957 .setResource(resource) 958 .setRegionSetLabelsRequestResource(regionSetLabelsRequestResource) 959 .build(); 960 return setLabelsAsync(request); 961 } 962 963 // AUTO-GENERATED DOCUMENTATION AND METHOD. 964 /** 965 * Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources 966 * documentation. 967 * 968 * <p>Sample code: 969 * 970 * <pre>{@code 971 * // This snippet has been automatically generated and should be regarded as a code template only. 972 * // It will require modifications to work: 973 * // - It may require correct/in-range values for request initialization. 974 * // - It may require specifying regional endpoints when creating the service client as shown in 975 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 976 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 977 * SetLabelsVpnGatewayRequest request = 978 * SetLabelsVpnGatewayRequest.newBuilder() 979 * .setProject("project-309310695") 980 * .setRegion("region-934795532") 981 * .setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build()) 982 * .setRequestId("requestId693933066") 983 * .setResource("resource-341064690") 984 * .build(); 985 * Operation response = vpnGatewaysClient.setLabelsAsync(request).get(); 986 * } 987 * }</pre> 988 * 989 * @param request The request object containing all of the parameters for the API call. 990 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 991 */ 992 @BetaApi( 993 "The surface for long-running operations is not stable yet and may change in the future.") setLabelsAsync( SetLabelsVpnGatewayRequest request)994 public final OperationFuture<Operation, Operation> setLabelsAsync( 995 SetLabelsVpnGatewayRequest request) { 996 return setLabelsOperationCallable().futureCall(request); 997 } 998 999 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1000 /** 1001 * Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources 1002 * documentation. 1003 * 1004 * <p>Sample code: 1005 * 1006 * <pre>{@code 1007 * // This snippet has been automatically generated and should be regarded as a code template only. 1008 * // It will require modifications to work: 1009 * // - It may require correct/in-range values for request initialization. 1010 * // - It may require specifying regional endpoints when creating the service client as shown in 1011 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1012 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 1013 * SetLabelsVpnGatewayRequest request = 1014 * SetLabelsVpnGatewayRequest.newBuilder() 1015 * .setProject("project-309310695") 1016 * .setRegion("region-934795532") 1017 * .setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build()) 1018 * .setRequestId("requestId693933066") 1019 * .setResource("resource-341064690") 1020 * .build(); 1021 * OperationFuture<Operation, Operation> future = 1022 * vpnGatewaysClient.setLabelsOperationCallable().futureCall(request); 1023 * // Do something. 1024 * Operation response = future.get(); 1025 * } 1026 * }</pre> 1027 */ 1028 public final OperationCallable<SetLabelsVpnGatewayRequest, Operation, Operation> setLabelsOperationCallable()1029 setLabelsOperationCallable() { 1030 return stub.setLabelsOperationCallable(); 1031 } 1032 1033 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1034 /** 1035 * Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources 1036 * documentation. 1037 * 1038 * <p>Sample code: 1039 * 1040 * <pre>{@code 1041 * // This snippet has been automatically generated and should be regarded as a code template only. 1042 * // It will require modifications to work: 1043 * // - It may require correct/in-range values for request initialization. 1044 * // - It may require specifying regional endpoints when creating the service client as shown in 1045 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1046 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 1047 * SetLabelsVpnGatewayRequest request = 1048 * SetLabelsVpnGatewayRequest.newBuilder() 1049 * .setProject("project-309310695") 1050 * .setRegion("region-934795532") 1051 * .setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build()) 1052 * .setRequestId("requestId693933066") 1053 * .setResource("resource-341064690") 1054 * .build(); 1055 * ApiFuture<Operation> future = vpnGatewaysClient.setLabelsCallable().futureCall(request); 1056 * // Do something. 1057 * Operation response = future.get(); 1058 * } 1059 * }</pre> 1060 */ setLabelsCallable()1061 public final UnaryCallable<SetLabelsVpnGatewayRequest, Operation> setLabelsCallable() { 1062 return stub.setLabelsCallable(); 1063 } 1064 1065 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1066 /** 1067 * Returns permissions that a caller has on the specified resource. 1068 * 1069 * <p>Sample code: 1070 * 1071 * <pre>{@code 1072 * // This snippet has been automatically generated and should be regarded as a code template only. 1073 * // It will require modifications to work: 1074 * // - It may require correct/in-range values for request initialization. 1075 * // - It may require specifying regional endpoints when creating the service client as shown in 1076 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1077 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 1078 * String project = "project-309310695"; 1079 * String region = "region-934795532"; 1080 * String resource = "resource-341064690"; 1081 * TestPermissionsRequest testPermissionsRequestResource = 1082 * TestPermissionsRequest.newBuilder().build(); 1083 * TestPermissionsResponse response = 1084 * vpnGatewaysClient.testIamPermissions( 1085 * project, region, resource, testPermissionsRequestResource); 1086 * } 1087 * }</pre> 1088 * 1089 * @param project Project ID for this request. 1090 * @param region The name of the region for this request. 1091 * @param resource Name or id of the resource for this request. 1092 * @param testPermissionsRequestResource The body resource for this request 1093 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1094 */ testIamPermissions( String project, String region, String resource, TestPermissionsRequest testPermissionsRequestResource)1095 public final TestPermissionsResponse testIamPermissions( 1096 String project, 1097 String region, 1098 String resource, 1099 TestPermissionsRequest testPermissionsRequestResource) { 1100 TestIamPermissionsVpnGatewayRequest request = 1101 TestIamPermissionsVpnGatewayRequest.newBuilder() 1102 .setProject(project) 1103 .setRegion(region) 1104 .setResource(resource) 1105 .setTestPermissionsRequestResource(testPermissionsRequestResource) 1106 .build(); 1107 return testIamPermissions(request); 1108 } 1109 1110 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1111 /** 1112 * Returns permissions that a caller has on the specified resource. 1113 * 1114 * <p>Sample code: 1115 * 1116 * <pre>{@code 1117 * // This snippet has been automatically generated and should be regarded as a code template only. 1118 * // It will require modifications to work: 1119 * // - It may require correct/in-range values for request initialization. 1120 * // - It may require specifying regional endpoints when creating the service client as shown in 1121 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1122 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 1123 * TestIamPermissionsVpnGatewayRequest request = 1124 * TestIamPermissionsVpnGatewayRequest.newBuilder() 1125 * .setProject("project-309310695") 1126 * .setRegion("region-934795532") 1127 * .setResource("resource-341064690") 1128 * .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build()) 1129 * .build(); 1130 * TestPermissionsResponse response = vpnGatewaysClient.testIamPermissions(request); 1131 * } 1132 * }</pre> 1133 * 1134 * @param request The request object containing all of the parameters for the API call. 1135 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1136 */ testIamPermissions( TestIamPermissionsVpnGatewayRequest request)1137 public final TestPermissionsResponse testIamPermissions( 1138 TestIamPermissionsVpnGatewayRequest request) { 1139 return testIamPermissionsCallable().call(request); 1140 } 1141 1142 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1143 /** 1144 * Returns permissions that a caller has on the specified resource. 1145 * 1146 * <p>Sample code: 1147 * 1148 * <pre>{@code 1149 * // This snippet has been automatically generated and should be regarded as a code template only. 1150 * // It will require modifications to work: 1151 * // - It may require correct/in-range values for request initialization. 1152 * // - It may require specifying regional endpoints when creating the service client as shown in 1153 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1154 * try (VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.create()) { 1155 * TestIamPermissionsVpnGatewayRequest request = 1156 * TestIamPermissionsVpnGatewayRequest.newBuilder() 1157 * .setProject("project-309310695") 1158 * .setRegion("region-934795532") 1159 * .setResource("resource-341064690") 1160 * .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build()) 1161 * .build(); 1162 * ApiFuture<TestPermissionsResponse> future = 1163 * vpnGatewaysClient.testIamPermissionsCallable().futureCall(request); 1164 * // Do something. 1165 * TestPermissionsResponse response = future.get(); 1166 * } 1167 * }</pre> 1168 */ 1169 public final UnaryCallable<TestIamPermissionsVpnGatewayRequest, TestPermissionsResponse> testIamPermissionsCallable()1170 testIamPermissionsCallable() { 1171 return stub.testIamPermissionsCallable(); 1172 } 1173 1174 @Override close()1175 public final void close() { 1176 stub.close(); 1177 } 1178 1179 @Override shutdown()1180 public void shutdown() { 1181 stub.shutdown(); 1182 } 1183 1184 @Override isShutdown()1185 public boolean isShutdown() { 1186 return stub.isShutdown(); 1187 } 1188 1189 @Override isTerminated()1190 public boolean isTerminated() { 1191 return stub.isTerminated(); 1192 } 1193 1194 @Override shutdownNow()1195 public void shutdownNow() { 1196 stub.shutdownNow(); 1197 } 1198 1199 @Override awaitTermination(long duration, TimeUnit unit)1200 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 1201 return stub.awaitTermination(duration, unit); 1202 } 1203 1204 public static class AggregatedListPagedResponse 1205 extends AbstractPagedListResponse< 1206 AggregatedListVpnGatewaysRequest, 1207 VpnGatewayAggregatedList, 1208 Map.Entry<String, VpnGatewaysScopedList>, 1209 AggregatedListPage, 1210 AggregatedListFixedSizeCollection> { 1211 createAsync( PageContext< AggregatedListVpnGatewaysRequest, VpnGatewayAggregatedList, Map.Entry<String, VpnGatewaysScopedList>> context, ApiFuture<VpnGatewayAggregatedList> futureResponse)1212 public static ApiFuture<AggregatedListPagedResponse> createAsync( 1213 PageContext< 1214 AggregatedListVpnGatewaysRequest, 1215 VpnGatewayAggregatedList, 1216 Map.Entry<String, VpnGatewaysScopedList>> 1217 context, 1218 ApiFuture<VpnGatewayAggregatedList> futureResponse) { 1219 ApiFuture<AggregatedListPage> futurePage = 1220 AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse); 1221 return ApiFutures.transform( 1222 futurePage, 1223 input -> new AggregatedListPagedResponse(input), 1224 MoreExecutors.directExecutor()); 1225 } 1226 AggregatedListPagedResponse(AggregatedListPage page)1227 private AggregatedListPagedResponse(AggregatedListPage page) { 1228 super(page, AggregatedListFixedSizeCollection.createEmptyCollection()); 1229 } 1230 } 1231 1232 public static class AggregatedListPage 1233 extends AbstractPage< 1234 AggregatedListVpnGatewaysRequest, 1235 VpnGatewayAggregatedList, 1236 Map.Entry<String, VpnGatewaysScopedList>, 1237 AggregatedListPage> { 1238 AggregatedListPage( PageContext< AggregatedListVpnGatewaysRequest, VpnGatewayAggregatedList, Map.Entry<String, VpnGatewaysScopedList>> context, VpnGatewayAggregatedList response)1239 private AggregatedListPage( 1240 PageContext< 1241 AggregatedListVpnGatewaysRequest, 1242 VpnGatewayAggregatedList, 1243 Map.Entry<String, VpnGatewaysScopedList>> 1244 context, 1245 VpnGatewayAggregatedList response) { 1246 super(context, response); 1247 } 1248 createEmptyPage()1249 private static AggregatedListPage createEmptyPage() { 1250 return new AggregatedListPage(null, null); 1251 } 1252 1253 @Override createPage( PageContext< AggregatedListVpnGatewaysRequest, VpnGatewayAggregatedList, Map.Entry<String, VpnGatewaysScopedList>> context, VpnGatewayAggregatedList response)1254 protected AggregatedListPage createPage( 1255 PageContext< 1256 AggregatedListVpnGatewaysRequest, 1257 VpnGatewayAggregatedList, 1258 Map.Entry<String, VpnGatewaysScopedList>> 1259 context, 1260 VpnGatewayAggregatedList response) { 1261 return new AggregatedListPage(context, response); 1262 } 1263 1264 @Override createPageAsync( PageContext< AggregatedListVpnGatewaysRequest, VpnGatewayAggregatedList, Map.Entry<String, VpnGatewaysScopedList>> context, ApiFuture<VpnGatewayAggregatedList> futureResponse)1265 public ApiFuture<AggregatedListPage> createPageAsync( 1266 PageContext< 1267 AggregatedListVpnGatewaysRequest, 1268 VpnGatewayAggregatedList, 1269 Map.Entry<String, VpnGatewaysScopedList>> 1270 context, 1271 ApiFuture<VpnGatewayAggregatedList> futureResponse) { 1272 return super.createPageAsync(context, futureResponse); 1273 } 1274 } 1275 1276 public static class AggregatedListFixedSizeCollection 1277 extends AbstractFixedSizeCollection< 1278 AggregatedListVpnGatewaysRequest, 1279 VpnGatewayAggregatedList, 1280 Map.Entry<String, VpnGatewaysScopedList>, 1281 AggregatedListPage, 1282 AggregatedListFixedSizeCollection> { 1283 AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize)1284 private AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize) { 1285 super(pages, collectionSize); 1286 } 1287 createEmptyCollection()1288 private static AggregatedListFixedSizeCollection createEmptyCollection() { 1289 return new AggregatedListFixedSizeCollection(null, 0); 1290 } 1291 1292 @Override createCollection( List<AggregatedListPage> pages, int collectionSize)1293 protected AggregatedListFixedSizeCollection createCollection( 1294 List<AggregatedListPage> pages, int collectionSize) { 1295 return new AggregatedListFixedSizeCollection(pages, collectionSize); 1296 } 1297 } 1298 1299 public static class ListPagedResponse 1300 extends AbstractPagedListResponse< 1301 ListVpnGatewaysRequest, VpnGatewayList, VpnGateway, ListPage, ListFixedSizeCollection> { 1302 createAsync( PageContext<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway> context, ApiFuture<VpnGatewayList> futureResponse)1303 public static ApiFuture<ListPagedResponse> createAsync( 1304 PageContext<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway> context, 1305 ApiFuture<VpnGatewayList> futureResponse) { 1306 ApiFuture<ListPage> futurePage = 1307 ListPage.createEmptyPage().createPageAsync(context, futureResponse); 1308 return ApiFutures.transform( 1309 futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor()); 1310 } 1311 ListPagedResponse(ListPage page)1312 private ListPagedResponse(ListPage page) { 1313 super(page, ListFixedSizeCollection.createEmptyCollection()); 1314 } 1315 } 1316 1317 public static class ListPage 1318 extends AbstractPage<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway, ListPage> { 1319 ListPage( PageContext<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway> context, VpnGatewayList response)1320 private ListPage( 1321 PageContext<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway> context, 1322 VpnGatewayList response) { 1323 super(context, response); 1324 } 1325 createEmptyPage()1326 private static ListPage createEmptyPage() { 1327 return new ListPage(null, null); 1328 } 1329 1330 @Override createPage( PageContext<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway> context, VpnGatewayList response)1331 protected ListPage createPage( 1332 PageContext<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway> context, 1333 VpnGatewayList response) { 1334 return new ListPage(context, response); 1335 } 1336 1337 @Override createPageAsync( PageContext<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway> context, ApiFuture<VpnGatewayList> futureResponse)1338 public ApiFuture<ListPage> createPageAsync( 1339 PageContext<ListVpnGatewaysRequest, VpnGatewayList, VpnGateway> context, 1340 ApiFuture<VpnGatewayList> futureResponse) { 1341 return super.createPageAsync(context, futureResponse); 1342 } 1343 } 1344 1345 public static class ListFixedSizeCollection 1346 extends AbstractFixedSizeCollection< 1347 ListVpnGatewaysRequest, VpnGatewayList, VpnGateway, ListPage, ListFixedSizeCollection> { 1348 ListFixedSizeCollection(List<ListPage> pages, int collectionSize)1349 private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) { 1350 super(pages, collectionSize); 1351 } 1352 createEmptyCollection()1353 private static ListFixedSizeCollection createEmptyCollection() { 1354 return new ListFixedSizeCollection(null, 0); 1355 } 1356 1357 @Override createCollection(List<ListPage> pages, int collectionSize)1358 protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) { 1359 return new ListFixedSizeCollection(pages, collectionSize); 1360 } 1361 } 1362 } 1363