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