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