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