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.DisksStub; 31 import com.google.cloud.compute.v1.stub.DisksStubSettings; 32 import com.google.common.util.concurrent.MoreExecutors; 33 import java.io.IOException; 34 import java.util.List; 35 import java.util.Map; 36 import java.util.concurrent.TimeUnit; 37 import javax.annotation.Generated; 38 39 // AUTO-GENERATED DOCUMENTATION AND CLASS. 40 /** 41 * Service Description: The Disks API. 42 * 43 * <p>This class provides the ability to make remote calls to the backing service through method 44 * calls that map to API methods. Sample code to get started: 45 * 46 * <pre>{@code 47 * // This snippet has been automatically generated and should be regarded as a code template only. 48 * // It will require modifications to work: 49 * // - It may require correct/in-range values for request initialization. 50 * // - It may require specifying regional endpoints when creating the service client as shown in 51 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 52 * try (DisksClient disksClient = DisksClient.create()) { 53 * String project = "project-309310695"; 54 * String zone = "zone3744684"; 55 * String disk = "disk3083677"; 56 * Disk response = disksClient.get(project, zone, disk); 57 * } 58 * }</pre> 59 * 60 * <p>Note: close() needs to be called on the DisksClient object to clean up resources such as 61 * threads. In the example above, try-with-resources is used, which automatically calls close(). 62 * 63 * <p>The surface of this class includes several types of Java methods for each of the API's 64 * methods: 65 * 66 * <ol> 67 * <li>A "flattened" method. With this type of method, the fields of the request type have been 68 * converted into function parameters. It may be the case that not all fields are available as 69 * parameters, and not every API method will have a flattened method entry point. 70 * <li>A "request object" method. This type of method only takes one parameter, a request object, 71 * which must be constructed before the call. Not every API method will have a request object 72 * method. 73 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 74 * callable object, which can be used to initiate calls to the service. 75 * </ol> 76 * 77 * <p>See the individual methods for example code. 78 * 79 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 80 * these names, this class includes a format method for each type of name, and additionally a parse 81 * method to extract the individual identifiers contained within names that are returned. 82 * 83 * <p>This class can be customized by passing in a custom instance of DisksSettings to create(). For 84 * example: 85 * 86 * <p>To customize credentials: 87 * 88 * <pre>{@code 89 * // This snippet has been automatically generated and should be regarded as a code template only. 90 * // It will require modifications to work: 91 * // - It may require correct/in-range values for request initialization. 92 * // - It may require specifying regional endpoints when creating the service client as shown in 93 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 94 * DisksSettings disksSettings = 95 * DisksSettings.newBuilder() 96 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 97 * .build(); 98 * DisksClient disksClient = DisksClient.create(disksSettings); 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 * DisksSettings disksSettings = DisksSettings.newBuilder().setEndpoint(myEndpoint).build(); 110 * DisksClient disksClient = DisksClient.create(disksSettings); 111 * }</pre> 112 * 113 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 114 */ 115 @Generated("by gapic-generator-java") 116 public class DisksClient implements BackgroundResource { 117 private final DisksSettings settings; 118 private final DisksStub stub; 119 120 /** Constructs an instance of DisksClient with default settings. */ create()121 public static final DisksClient create() throws IOException { 122 return create(DisksSettings.newBuilder().build()); 123 } 124 125 /** 126 * Constructs an instance of DisksClient, using the given settings. The channels are created based 127 * on the settings passed in, or defaults for any settings that are not set. 128 */ create(DisksSettings settings)129 public static final DisksClient create(DisksSettings settings) throws IOException { 130 return new DisksClient(settings); 131 } 132 133 /** 134 * Constructs an instance of DisksClient, using the given stub for making calls. This is for 135 * advanced usage - prefer using create(DisksSettings). 136 */ create(DisksStub stub)137 public static final DisksClient create(DisksStub stub) { 138 return new DisksClient(stub); 139 } 140 141 /** 142 * Constructs an instance of DisksClient, using the given settings. This is protected so that it 143 * is easy to make a subclass, but otherwise, the static factory methods should be preferred. 144 */ DisksClient(DisksSettings settings)145 protected DisksClient(DisksSettings settings) throws IOException { 146 this.settings = settings; 147 this.stub = ((DisksStubSettings) settings.getStubSettings()).createStub(); 148 } 149 DisksClient(DisksStub stub)150 protected DisksClient(DisksStub stub) { 151 this.settings = null; 152 this.stub = stub; 153 } 154 getSettings()155 public final DisksSettings getSettings() { 156 return settings; 157 } 158 getStub()159 public DisksStub getStub() { 160 return stub; 161 } 162 163 // AUTO-GENERATED DOCUMENTATION AND METHOD. 164 /** 165 * Adds existing resource policies to a disk. You can only add one policy which will be applied to 166 * this disk for scheduling snapshot creation. 167 * 168 * <p>Sample code: 169 * 170 * <pre>{@code 171 * // This snippet has been automatically generated and should be regarded as a code template only. 172 * // It will require modifications to work: 173 * // - It may require correct/in-range values for request initialization. 174 * // - It may require specifying regional endpoints when creating the service client as shown in 175 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 176 * try (DisksClient disksClient = DisksClient.create()) { 177 * String project = "project-309310695"; 178 * String zone = "zone3744684"; 179 * String disk = "disk3083677"; 180 * DisksAddResourcePoliciesRequest disksAddResourcePoliciesRequestResource = 181 * DisksAddResourcePoliciesRequest.newBuilder().build(); 182 * Operation response = 183 * disksClient 184 * .addResourcePoliciesAsync( 185 * project, zone, disk, disksAddResourcePoliciesRequestResource) 186 * .get(); 187 * } 188 * }</pre> 189 * 190 * @param project Project ID for this request. 191 * @param zone The name of the zone for this request. 192 * @param disk The disk name for this request. 193 * @param disksAddResourcePoliciesRequestResource The body resource for this request 194 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 195 */ addResourcePoliciesAsync( String project, String zone, String disk, DisksAddResourcePoliciesRequest disksAddResourcePoliciesRequestResource)196 public final OperationFuture<Operation, Operation> addResourcePoliciesAsync( 197 String project, 198 String zone, 199 String disk, 200 DisksAddResourcePoliciesRequest disksAddResourcePoliciesRequestResource) { 201 AddResourcePoliciesDiskRequest request = 202 AddResourcePoliciesDiskRequest.newBuilder() 203 .setProject(project) 204 .setZone(zone) 205 .setDisk(disk) 206 .setDisksAddResourcePoliciesRequestResource(disksAddResourcePoliciesRequestResource) 207 .build(); 208 return addResourcePoliciesAsync(request); 209 } 210 211 // AUTO-GENERATED DOCUMENTATION AND METHOD. 212 /** 213 * Adds existing resource policies to a disk. You can only add one policy which will be applied to 214 * this disk for scheduling snapshot creation. 215 * 216 * <p>Sample code: 217 * 218 * <pre>{@code 219 * // This snippet has been automatically generated and should be regarded as a code template only. 220 * // It will require modifications to work: 221 * // - It may require correct/in-range values for request initialization. 222 * // - It may require specifying regional endpoints when creating the service client as shown in 223 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 224 * try (DisksClient disksClient = DisksClient.create()) { 225 * AddResourcePoliciesDiskRequest request = 226 * AddResourcePoliciesDiskRequest.newBuilder() 227 * .setDisk("disk3083677") 228 * .setDisksAddResourcePoliciesRequestResource( 229 * DisksAddResourcePoliciesRequest.newBuilder().build()) 230 * .setProject("project-309310695") 231 * .setRequestId("requestId693933066") 232 * .setZone("zone3744684") 233 * .build(); 234 * Operation response = disksClient.addResourcePoliciesAsync(request).get(); 235 * } 236 * }</pre> 237 * 238 * @param request The request object containing all of the parameters for the API call. 239 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 240 */ 241 @BetaApi( 242 "The surface for long-running operations is not stable yet and may change in the future.") addResourcePoliciesAsync( AddResourcePoliciesDiskRequest request)243 public final OperationFuture<Operation, Operation> addResourcePoliciesAsync( 244 AddResourcePoliciesDiskRequest request) { 245 return addResourcePoliciesOperationCallable().futureCall(request); 246 } 247 248 // AUTO-GENERATED DOCUMENTATION AND METHOD. 249 /** 250 * Adds existing resource policies to a disk. You can only add one policy which will be applied to 251 * this disk for scheduling snapshot creation. 252 * 253 * <p>Sample code: 254 * 255 * <pre>{@code 256 * // This snippet has been automatically generated and should be regarded as a code template only. 257 * // It will require modifications to work: 258 * // - It may require correct/in-range values for request initialization. 259 * // - It may require specifying regional endpoints when creating the service client as shown in 260 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 261 * try (DisksClient disksClient = DisksClient.create()) { 262 * AddResourcePoliciesDiskRequest request = 263 * AddResourcePoliciesDiskRequest.newBuilder() 264 * .setDisk("disk3083677") 265 * .setDisksAddResourcePoliciesRequestResource( 266 * DisksAddResourcePoliciesRequest.newBuilder().build()) 267 * .setProject("project-309310695") 268 * .setRequestId("requestId693933066") 269 * .setZone("zone3744684") 270 * .build(); 271 * OperationFuture<Operation, Operation> future = 272 * disksClient.addResourcePoliciesOperationCallable().futureCall(request); 273 * // Do something. 274 * Operation response = future.get(); 275 * } 276 * }</pre> 277 */ 278 public final OperationCallable<AddResourcePoliciesDiskRequest, Operation, Operation> addResourcePoliciesOperationCallable()279 addResourcePoliciesOperationCallable() { 280 return stub.addResourcePoliciesOperationCallable(); 281 } 282 283 // AUTO-GENERATED DOCUMENTATION AND METHOD. 284 /** 285 * Adds existing resource policies to a disk. You can only add one policy which will be applied to 286 * this disk for scheduling snapshot creation. 287 * 288 * <p>Sample code: 289 * 290 * <pre>{@code 291 * // This snippet has been automatically generated and should be regarded as a code template only. 292 * // It will require modifications to work: 293 * // - It may require correct/in-range values for request initialization. 294 * // - It may require specifying regional endpoints when creating the service client as shown in 295 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 296 * try (DisksClient disksClient = DisksClient.create()) { 297 * AddResourcePoliciesDiskRequest request = 298 * AddResourcePoliciesDiskRequest.newBuilder() 299 * .setDisk("disk3083677") 300 * .setDisksAddResourcePoliciesRequestResource( 301 * DisksAddResourcePoliciesRequest.newBuilder().build()) 302 * .setProject("project-309310695") 303 * .setRequestId("requestId693933066") 304 * .setZone("zone3744684") 305 * .build(); 306 * ApiFuture<Operation> future = disksClient.addResourcePoliciesCallable().futureCall(request); 307 * // Do something. 308 * Operation response = future.get(); 309 * } 310 * }</pre> 311 */ 312 public final UnaryCallable<AddResourcePoliciesDiskRequest, Operation> addResourcePoliciesCallable()313 addResourcePoliciesCallable() { 314 return stub.addResourcePoliciesCallable(); 315 } 316 317 // AUTO-GENERATED DOCUMENTATION AND METHOD. 318 /** 319 * Retrieves an aggregated list of persistent disks. 320 * 321 * <p>Sample code: 322 * 323 * <pre>{@code 324 * // This snippet has been automatically generated and should be regarded as a code template only. 325 * // It will require modifications to work: 326 * // - It may require correct/in-range values for request initialization. 327 * // - It may require specifying regional endpoints when creating the service client as shown in 328 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 329 * try (DisksClient disksClient = DisksClient.create()) { 330 * String project = "project-309310695"; 331 * for (Map.Entry<String, DisksScopedList> element : 332 * disksClient.aggregatedList(project).iterateAll()) { 333 * // doThingsWith(element); 334 * } 335 * } 336 * }</pre> 337 * 338 * @param project Project ID for this request. 339 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 340 */ aggregatedList(String project)341 public final AggregatedListPagedResponse aggregatedList(String project) { 342 AggregatedListDisksRequest request = 343 AggregatedListDisksRequest.newBuilder().setProject(project).build(); 344 return aggregatedList(request); 345 } 346 347 // AUTO-GENERATED DOCUMENTATION AND METHOD. 348 /** 349 * Retrieves an aggregated list of persistent disks. 350 * 351 * <p>Sample code: 352 * 353 * <pre>{@code 354 * // This snippet has been automatically generated and should be regarded as a code template only. 355 * // It will require modifications to work: 356 * // - It may require correct/in-range values for request initialization. 357 * // - It may require specifying regional endpoints when creating the service client as shown in 358 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 359 * try (DisksClient disksClient = DisksClient.create()) { 360 * AggregatedListDisksRequest request = 361 * AggregatedListDisksRequest.newBuilder() 362 * .setFilter("filter-1274492040") 363 * .setIncludeAllScopes(true) 364 * .setMaxResults(1128457243) 365 * .setOrderBy("orderBy-1207110587") 366 * .setPageToken("pageToken873572522") 367 * .setProject("project-309310695") 368 * .setReturnPartialSuccess(true) 369 * .build(); 370 * for (Map.Entry<String, DisksScopedList> element : 371 * disksClient.aggregatedList(request).iterateAll()) { 372 * // doThingsWith(element); 373 * } 374 * } 375 * }</pre> 376 * 377 * @param request The request object containing all of the parameters for the API call. 378 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 379 */ aggregatedList(AggregatedListDisksRequest request)380 public final AggregatedListPagedResponse aggregatedList(AggregatedListDisksRequest request) { 381 return aggregatedListPagedCallable().call(request); 382 } 383 384 // AUTO-GENERATED DOCUMENTATION AND METHOD. 385 /** 386 * Retrieves an aggregated list of persistent disks. 387 * 388 * <p>Sample code: 389 * 390 * <pre>{@code 391 * // This snippet has been automatically generated and should be regarded as a code template only. 392 * // It will require modifications to work: 393 * // - It may require correct/in-range values for request initialization. 394 * // - It may require specifying regional endpoints when creating the service client as shown in 395 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 396 * try (DisksClient disksClient = DisksClient.create()) { 397 * AggregatedListDisksRequest request = 398 * AggregatedListDisksRequest.newBuilder() 399 * .setFilter("filter-1274492040") 400 * .setIncludeAllScopes(true) 401 * .setMaxResults(1128457243) 402 * .setOrderBy("orderBy-1207110587") 403 * .setPageToken("pageToken873572522") 404 * .setProject("project-309310695") 405 * .setReturnPartialSuccess(true) 406 * .build(); 407 * ApiFuture<Map.Entry<String, DisksScopedList>> future = 408 * disksClient.aggregatedListPagedCallable().futureCall(request); 409 * // Do something. 410 * for (Map.Entry<String, DisksScopedList> element : future.get().iterateAll()) { 411 * // doThingsWith(element); 412 * } 413 * } 414 * }</pre> 415 */ 416 public final UnaryCallable<AggregatedListDisksRequest, AggregatedListPagedResponse> aggregatedListPagedCallable()417 aggregatedListPagedCallable() { 418 return stub.aggregatedListPagedCallable(); 419 } 420 421 // AUTO-GENERATED DOCUMENTATION AND METHOD. 422 /** 423 * Retrieves an aggregated list of persistent disks. 424 * 425 * <p>Sample code: 426 * 427 * <pre>{@code 428 * // This snippet has been automatically generated and should be regarded as a code template only. 429 * // It will require modifications to work: 430 * // - It may require correct/in-range values for request initialization. 431 * // - It may require specifying regional endpoints when creating the service client as shown in 432 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 433 * try (DisksClient disksClient = DisksClient.create()) { 434 * AggregatedListDisksRequest request = 435 * AggregatedListDisksRequest.newBuilder() 436 * .setFilter("filter-1274492040") 437 * .setIncludeAllScopes(true) 438 * .setMaxResults(1128457243) 439 * .setOrderBy("orderBy-1207110587") 440 * .setPageToken("pageToken873572522") 441 * .setProject("project-309310695") 442 * .setReturnPartialSuccess(true) 443 * .build(); 444 * while (true) { 445 * DiskAggregatedList response = disksClient.aggregatedListCallable().call(request); 446 * for (Map.Entry<String, DisksScopedList> element : response.getItemsList()) { 447 * // doThingsWith(element); 448 * } 449 * String nextPageToken = response.getNextPageToken(); 450 * if (!Strings.isNullOrEmpty(nextPageToken)) { 451 * request = request.toBuilder().setPageToken(nextPageToken).build(); 452 * } else { 453 * break; 454 * } 455 * } 456 * } 457 * }</pre> 458 */ 459 public final UnaryCallable<AggregatedListDisksRequest, DiskAggregatedList> aggregatedListCallable()460 aggregatedListCallable() { 461 return stub.aggregatedListCallable(); 462 } 463 464 // AUTO-GENERATED DOCUMENTATION AND METHOD. 465 /** 466 * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider 467 * using snapshots.insert instead, as that method supports more features, such as creating 468 * snapshots in a project different from the source disk project. 469 * 470 * <p>Sample code: 471 * 472 * <pre>{@code 473 * // This snippet has been automatically generated and should be regarded as a code template only. 474 * // It will require modifications to work: 475 * // - It may require correct/in-range values for request initialization. 476 * // - It may require specifying regional endpoints when creating the service client as shown in 477 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 478 * try (DisksClient disksClient = DisksClient.create()) { 479 * String project = "project-309310695"; 480 * String zone = "zone3744684"; 481 * String disk = "disk3083677"; 482 * Snapshot snapshotResource = Snapshot.newBuilder().build(); 483 * Operation response = 484 * disksClient.createSnapshotAsync(project, zone, disk, snapshotResource).get(); 485 * } 486 * }</pre> 487 * 488 * @param project Project ID for this request. 489 * @param zone The name of the zone for this request. 490 * @param disk Name of the persistent disk to snapshot. 491 * @param snapshotResource The body resource for this request 492 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 493 */ createSnapshotAsync( String project, String zone, String disk, Snapshot snapshotResource)494 public final OperationFuture<Operation, Operation> createSnapshotAsync( 495 String project, String zone, String disk, Snapshot snapshotResource) { 496 CreateSnapshotDiskRequest request = 497 CreateSnapshotDiskRequest.newBuilder() 498 .setProject(project) 499 .setZone(zone) 500 .setDisk(disk) 501 .setSnapshotResource(snapshotResource) 502 .build(); 503 return createSnapshotAsync(request); 504 } 505 506 // AUTO-GENERATED DOCUMENTATION AND METHOD. 507 /** 508 * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider 509 * using snapshots.insert instead, as that method supports more features, such as creating 510 * snapshots in a project different from the source disk project. 511 * 512 * <p>Sample code: 513 * 514 * <pre>{@code 515 * // This snippet has been automatically generated and should be regarded as a code template only. 516 * // It will require modifications to work: 517 * // - It may require correct/in-range values for request initialization. 518 * // - It may require specifying regional endpoints when creating the service client as shown in 519 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 520 * try (DisksClient disksClient = DisksClient.create()) { 521 * CreateSnapshotDiskRequest request = 522 * CreateSnapshotDiskRequest.newBuilder() 523 * .setDisk("disk3083677") 524 * .setGuestFlush(true) 525 * .setProject("project-309310695") 526 * .setRequestId("requestId693933066") 527 * .setSnapshotResource(Snapshot.newBuilder().build()) 528 * .setZone("zone3744684") 529 * .build(); 530 * Operation response = disksClient.createSnapshotAsync(request).get(); 531 * } 532 * }</pre> 533 * 534 * @param request The request object containing all of the parameters for the API call. 535 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 536 */ 537 @BetaApi( 538 "The surface for long-running operations is not stable yet and may change in the future.") createSnapshotAsync( CreateSnapshotDiskRequest request)539 public final OperationFuture<Operation, Operation> createSnapshotAsync( 540 CreateSnapshotDiskRequest request) { 541 return createSnapshotOperationCallable().futureCall(request); 542 } 543 544 // AUTO-GENERATED DOCUMENTATION AND METHOD. 545 /** 546 * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider 547 * using snapshots.insert instead, as that method supports more features, such as creating 548 * snapshots in a project different from the source disk project. 549 * 550 * <p>Sample code: 551 * 552 * <pre>{@code 553 * // This snippet has been automatically generated and should be regarded as a code template only. 554 * // It will require modifications to work: 555 * // - It may require correct/in-range values for request initialization. 556 * // - It may require specifying regional endpoints when creating the service client as shown in 557 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 558 * try (DisksClient disksClient = DisksClient.create()) { 559 * CreateSnapshotDiskRequest request = 560 * CreateSnapshotDiskRequest.newBuilder() 561 * .setDisk("disk3083677") 562 * .setGuestFlush(true) 563 * .setProject("project-309310695") 564 * .setRequestId("requestId693933066") 565 * .setSnapshotResource(Snapshot.newBuilder().build()) 566 * .setZone("zone3744684") 567 * .build(); 568 * OperationFuture<Operation, Operation> future = 569 * disksClient.createSnapshotOperationCallable().futureCall(request); 570 * // Do something. 571 * Operation response = future.get(); 572 * } 573 * }</pre> 574 */ 575 public final OperationCallable<CreateSnapshotDiskRequest, Operation, Operation> createSnapshotOperationCallable()576 createSnapshotOperationCallable() { 577 return stub.createSnapshotOperationCallable(); 578 } 579 580 // AUTO-GENERATED DOCUMENTATION AND METHOD. 581 /** 582 * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider 583 * using snapshots.insert instead, as that method supports more features, such as creating 584 * snapshots in a project different from the source disk project. 585 * 586 * <p>Sample code: 587 * 588 * <pre>{@code 589 * // This snippet has been automatically generated and should be regarded as a code template only. 590 * // It will require modifications to work: 591 * // - It may require correct/in-range values for request initialization. 592 * // - It may require specifying regional endpoints when creating the service client as shown in 593 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 594 * try (DisksClient disksClient = DisksClient.create()) { 595 * CreateSnapshotDiskRequest request = 596 * CreateSnapshotDiskRequest.newBuilder() 597 * .setDisk("disk3083677") 598 * .setGuestFlush(true) 599 * .setProject("project-309310695") 600 * .setRequestId("requestId693933066") 601 * .setSnapshotResource(Snapshot.newBuilder().build()) 602 * .setZone("zone3744684") 603 * .build(); 604 * ApiFuture<Operation> future = disksClient.createSnapshotCallable().futureCall(request); 605 * // Do something. 606 * Operation response = future.get(); 607 * } 608 * }</pre> 609 */ createSnapshotCallable()610 public final UnaryCallable<CreateSnapshotDiskRequest, Operation> createSnapshotCallable() { 611 return stub.createSnapshotCallable(); 612 } 613 614 // AUTO-GENERATED DOCUMENTATION AND METHOD. 615 /** 616 * Deletes the specified persistent disk. Deleting a disk removes its data permanently and is 617 * irreversible. However, deleting a disk does not delete any snapshots previously made from the 618 * disk. You must separately delete snapshots. 619 * 620 * <p>Sample code: 621 * 622 * <pre>{@code 623 * // This snippet has been automatically generated and should be regarded as a code template only. 624 * // It will require modifications to work: 625 * // - It may require correct/in-range values for request initialization. 626 * // - It may require specifying regional endpoints when creating the service client as shown in 627 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 628 * try (DisksClient disksClient = DisksClient.create()) { 629 * String project = "project-309310695"; 630 * String zone = "zone3744684"; 631 * String disk = "disk3083677"; 632 * Operation response = disksClient.deleteAsync(project, zone, disk).get(); 633 * } 634 * }</pre> 635 * 636 * @param project Project ID for this request. 637 * @param zone The name of the zone for this request. 638 * @param disk Name of the persistent disk to delete. 639 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 640 */ deleteAsync( String project, String zone, String disk)641 public final OperationFuture<Operation, Operation> deleteAsync( 642 String project, String zone, String disk) { 643 DeleteDiskRequest request = 644 DeleteDiskRequest.newBuilder().setProject(project).setZone(zone).setDisk(disk).build(); 645 return deleteAsync(request); 646 } 647 648 // AUTO-GENERATED DOCUMENTATION AND METHOD. 649 /** 650 * Deletes the specified persistent disk. Deleting a disk removes its data permanently and is 651 * irreversible. However, deleting a disk does not delete any snapshots previously made from the 652 * disk. You must separately delete snapshots. 653 * 654 * <p>Sample code: 655 * 656 * <pre>{@code 657 * // This snippet has been automatically generated and should be regarded as a code template only. 658 * // It will require modifications to work: 659 * // - It may require correct/in-range values for request initialization. 660 * // - It may require specifying regional endpoints when creating the service client as shown in 661 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 662 * try (DisksClient disksClient = DisksClient.create()) { 663 * DeleteDiskRequest request = 664 * DeleteDiskRequest.newBuilder() 665 * .setDisk("disk3083677") 666 * .setProject("project-309310695") 667 * .setRequestId("requestId693933066") 668 * .setZone("zone3744684") 669 * .build(); 670 * Operation response = disksClient.deleteAsync(request).get(); 671 * } 672 * }</pre> 673 * 674 * @param request The request object containing all of the parameters for the API call. 675 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 676 */ 677 @BetaApi( 678 "The surface for long-running operations is not stable yet and may change in the future.") deleteAsync(DeleteDiskRequest request)679 public final OperationFuture<Operation, Operation> deleteAsync(DeleteDiskRequest request) { 680 return deleteOperationCallable().futureCall(request); 681 } 682 683 // AUTO-GENERATED DOCUMENTATION AND METHOD. 684 /** 685 * Deletes the specified persistent disk. Deleting a disk removes its data permanently and is 686 * irreversible. However, deleting a disk does not delete any snapshots previously made from the 687 * disk. You must separately delete snapshots. 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 (DisksClient disksClient = DisksClient.create()) { 698 * DeleteDiskRequest request = 699 * DeleteDiskRequest.newBuilder() 700 * .setDisk("disk3083677") 701 * .setProject("project-309310695") 702 * .setRequestId("requestId693933066") 703 * .setZone("zone3744684") 704 * .build(); 705 * OperationFuture<Operation, Operation> future = 706 * disksClient.deleteOperationCallable().futureCall(request); 707 * // Do something. 708 * Operation response = future.get(); 709 * } 710 * }</pre> 711 */ 712 public final OperationCallable<DeleteDiskRequest, Operation, Operation> deleteOperationCallable()713 deleteOperationCallable() { 714 return stub.deleteOperationCallable(); 715 } 716 717 // AUTO-GENERATED DOCUMENTATION AND METHOD. 718 /** 719 * Deletes the specified persistent disk. Deleting a disk removes its data permanently and is 720 * irreversible. However, deleting a disk does not delete any snapshots previously made from the 721 * disk. You must separately delete snapshots. 722 * 723 * <p>Sample code: 724 * 725 * <pre>{@code 726 * // This snippet has been automatically generated and should be regarded as a code template only. 727 * // It will require modifications to work: 728 * // - It may require correct/in-range values for request initialization. 729 * // - It may require specifying regional endpoints when creating the service client as shown in 730 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 731 * try (DisksClient disksClient = DisksClient.create()) { 732 * DeleteDiskRequest request = 733 * DeleteDiskRequest.newBuilder() 734 * .setDisk("disk3083677") 735 * .setProject("project-309310695") 736 * .setRequestId("requestId693933066") 737 * .setZone("zone3744684") 738 * .build(); 739 * ApiFuture<Operation> future = disksClient.deleteCallable().futureCall(request); 740 * // Do something. 741 * Operation response = future.get(); 742 * } 743 * }</pre> 744 */ deleteCallable()745 public final UnaryCallable<DeleteDiskRequest, Operation> deleteCallable() { 746 return stub.deleteCallable(); 747 } 748 749 // AUTO-GENERATED DOCUMENTATION AND METHOD. 750 /** 751 * Returns the specified persistent disk. 752 * 753 * <p>Sample code: 754 * 755 * <pre>{@code 756 * // This snippet has been automatically generated and should be regarded as a code template only. 757 * // It will require modifications to work: 758 * // - It may require correct/in-range values for request initialization. 759 * // - It may require specifying regional endpoints when creating the service client as shown in 760 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 761 * try (DisksClient disksClient = DisksClient.create()) { 762 * String project = "project-309310695"; 763 * String zone = "zone3744684"; 764 * String disk = "disk3083677"; 765 * Disk response = disksClient.get(project, zone, disk); 766 * } 767 * }</pre> 768 * 769 * @param project Project ID for this request. 770 * @param zone The name of the zone for this request. 771 * @param disk Name of the persistent disk to return. 772 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 773 */ get(String project, String zone, String disk)774 public final Disk get(String project, String zone, String disk) { 775 GetDiskRequest request = 776 GetDiskRequest.newBuilder().setProject(project).setZone(zone).setDisk(disk).build(); 777 return get(request); 778 } 779 780 // AUTO-GENERATED DOCUMENTATION AND METHOD. 781 /** 782 * Returns the specified persistent disk. 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 (DisksClient disksClient = DisksClient.create()) { 793 * GetDiskRequest request = 794 * GetDiskRequest.newBuilder() 795 * .setDisk("disk3083677") 796 * .setProject("project-309310695") 797 * .setZone("zone3744684") 798 * .build(); 799 * Disk response = disksClient.get(request); 800 * } 801 * }</pre> 802 * 803 * @param request The request object containing all of the parameters for the API call. 804 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 805 */ get(GetDiskRequest request)806 public final Disk get(GetDiskRequest request) { 807 return getCallable().call(request); 808 } 809 810 // AUTO-GENERATED DOCUMENTATION AND METHOD. 811 /** 812 * Returns the specified persistent disk. 813 * 814 * <p>Sample code: 815 * 816 * <pre>{@code 817 * // This snippet has been automatically generated and should be regarded as a code template only. 818 * // It will require modifications to work: 819 * // - It may require correct/in-range values for request initialization. 820 * // - It may require specifying regional endpoints when creating the service client as shown in 821 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 822 * try (DisksClient disksClient = DisksClient.create()) { 823 * GetDiskRequest request = 824 * GetDiskRequest.newBuilder() 825 * .setDisk("disk3083677") 826 * .setProject("project-309310695") 827 * .setZone("zone3744684") 828 * .build(); 829 * ApiFuture<Disk> future = disksClient.getCallable().futureCall(request); 830 * // Do something. 831 * Disk response = future.get(); 832 * } 833 * }</pre> 834 */ getCallable()835 public final UnaryCallable<GetDiskRequest, Disk> getCallable() { 836 return stub.getCallable(); 837 } 838 839 // AUTO-GENERATED DOCUMENTATION AND METHOD. 840 /** 841 * Gets the access control policy for a resource. May be empty if no such policy or resource 842 * exists. 843 * 844 * <p>Sample code: 845 * 846 * <pre>{@code 847 * // This snippet has been automatically generated and should be regarded as a code template only. 848 * // It will require modifications to work: 849 * // - It may require correct/in-range values for request initialization. 850 * // - It may require specifying regional endpoints when creating the service client as shown in 851 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 852 * try (DisksClient disksClient = DisksClient.create()) { 853 * String project = "project-309310695"; 854 * String zone = "zone3744684"; 855 * String resource = "resource-341064690"; 856 * Policy response = disksClient.getIamPolicy(project, zone, resource); 857 * } 858 * }</pre> 859 * 860 * @param project Project ID for this request. 861 * @param zone The name of the zone for this request. 862 * @param resource Name or id of the resource for this request. 863 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 864 */ getIamPolicy(String project, String zone, String resource)865 public final Policy getIamPolicy(String project, String zone, String resource) { 866 GetIamPolicyDiskRequest request = 867 GetIamPolicyDiskRequest.newBuilder() 868 .setProject(project) 869 .setZone(zone) 870 .setResource(resource) 871 .build(); 872 return getIamPolicy(request); 873 } 874 875 // AUTO-GENERATED DOCUMENTATION AND METHOD. 876 /** 877 * Gets the access control policy for a resource. May be empty if no such policy or resource 878 * exists. 879 * 880 * <p>Sample code: 881 * 882 * <pre>{@code 883 * // This snippet has been automatically generated and should be regarded as a code template only. 884 * // It will require modifications to work: 885 * // - It may require correct/in-range values for request initialization. 886 * // - It may require specifying regional endpoints when creating the service client as shown in 887 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 888 * try (DisksClient disksClient = DisksClient.create()) { 889 * GetIamPolicyDiskRequest request = 890 * GetIamPolicyDiskRequest.newBuilder() 891 * .setOptionsRequestedPolicyVersion(-574521795) 892 * .setProject("project-309310695") 893 * .setResource("resource-341064690") 894 * .setZone("zone3744684") 895 * .build(); 896 * Policy response = disksClient.getIamPolicy(request); 897 * } 898 * }</pre> 899 * 900 * @param request The request object containing all of the parameters for the API call. 901 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 902 */ getIamPolicy(GetIamPolicyDiskRequest request)903 public final Policy getIamPolicy(GetIamPolicyDiskRequest request) { 904 return getIamPolicyCallable().call(request); 905 } 906 907 // AUTO-GENERATED DOCUMENTATION AND METHOD. 908 /** 909 * Gets the access control policy for a resource. May be empty if no such policy or resource 910 * exists. 911 * 912 * <p>Sample code: 913 * 914 * <pre>{@code 915 * // This snippet has been automatically generated and should be regarded as a code template only. 916 * // It will require modifications to work: 917 * // - It may require correct/in-range values for request initialization. 918 * // - It may require specifying regional endpoints when creating the service client as shown in 919 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 920 * try (DisksClient disksClient = DisksClient.create()) { 921 * GetIamPolicyDiskRequest request = 922 * GetIamPolicyDiskRequest.newBuilder() 923 * .setOptionsRequestedPolicyVersion(-574521795) 924 * .setProject("project-309310695") 925 * .setResource("resource-341064690") 926 * .setZone("zone3744684") 927 * .build(); 928 * ApiFuture<Policy> future = disksClient.getIamPolicyCallable().futureCall(request); 929 * // Do something. 930 * Policy response = future.get(); 931 * } 932 * }</pre> 933 */ getIamPolicyCallable()934 public final UnaryCallable<GetIamPolicyDiskRequest, Policy> getIamPolicyCallable() { 935 return stub.getIamPolicyCallable(); 936 } 937 938 // AUTO-GENERATED DOCUMENTATION AND METHOD. 939 /** 940 * Creates a persistent disk in the specified project using the data in the request. You can 941 * create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 942 * GB data disk by omitting all properties. You can also create a disk that is larger than the 943 * default size by specifying the sizeGb property. 944 * 945 * <p>Sample code: 946 * 947 * <pre>{@code 948 * // This snippet has been automatically generated and should be regarded as a code template only. 949 * // It will require modifications to work: 950 * // - It may require correct/in-range values for request initialization. 951 * // - It may require specifying regional endpoints when creating the service client as shown in 952 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 953 * try (DisksClient disksClient = DisksClient.create()) { 954 * String project = "project-309310695"; 955 * String zone = "zone3744684"; 956 * Disk diskResource = Disk.newBuilder().build(); 957 * Operation response = disksClient.insertAsync(project, zone, diskResource).get(); 958 * } 959 * }</pre> 960 * 961 * @param project Project ID for this request. 962 * @param zone The name of the zone for this request. 963 * @param diskResource The body resource for this request 964 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 965 */ insertAsync( String project, String zone, Disk diskResource)966 public final OperationFuture<Operation, Operation> insertAsync( 967 String project, String zone, Disk diskResource) { 968 InsertDiskRequest request = 969 InsertDiskRequest.newBuilder() 970 .setProject(project) 971 .setZone(zone) 972 .setDiskResource(diskResource) 973 .build(); 974 return insertAsync(request); 975 } 976 977 // AUTO-GENERATED DOCUMENTATION AND METHOD. 978 /** 979 * Creates a persistent disk in the specified project using the data in the request. You can 980 * create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 981 * GB data disk by omitting all properties. You can also create a disk that is larger than the 982 * default size by specifying the sizeGb property. 983 * 984 * <p>Sample code: 985 * 986 * <pre>{@code 987 * // This snippet has been automatically generated and should be regarded as a code template only. 988 * // It will require modifications to work: 989 * // - It may require correct/in-range values for request initialization. 990 * // - It may require specifying regional endpoints when creating the service client as shown in 991 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 992 * try (DisksClient disksClient = DisksClient.create()) { 993 * InsertDiskRequest request = 994 * InsertDiskRequest.newBuilder() 995 * .setDiskResource(Disk.newBuilder().build()) 996 * .setProject("project-309310695") 997 * .setRequestId("requestId693933066") 998 * .setSourceImage("sourceImage-105174528") 999 * .setZone("zone3744684") 1000 * .build(); 1001 * Operation response = disksClient.insertAsync(request).get(); 1002 * } 1003 * }</pre> 1004 * 1005 * @param request The request object containing all of the parameters for the API call. 1006 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1007 */ 1008 @BetaApi( 1009 "The surface for long-running operations is not stable yet and may change in the future.") insertAsync(InsertDiskRequest request)1010 public final OperationFuture<Operation, Operation> insertAsync(InsertDiskRequest request) { 1011 return insertOperationCallable().futureCall(request); 1012 } 1013 1014 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1015 /** 1016 * Creates a persistent disk in the specified project using the data in the request. You can 1017 * create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 1018 * GB data disk by omitting all properties. You can also create a disk that is larger than the 1019 * default size by specifying the sizeGb property. 1020 * 1021 * <p>Sample code: 1022 * 1023 * <pre>{@code 1024 * // This snippet has been automatically generated and should be regarded as a code template only. 1025 * // It will require modifications to work: 1026 * // - It may require correct/in-range values for request initialization. 1027 * // - It may require specifying regional endpoints when creating the service client as shown in 1028 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1029 * try (DisksClient disksClient = DisksClient.create()) { 1030 * InsertDiskRequest request = 1031 * InsertDiskRequest.newBuilder() 1032 * .setDiskResource(Disk.newBuilder().build()) 1033 * .setProject("project-309310695") 1034 * .setRequestId("requestId693933066") 1035 * .setSourceImage("sourceImage-105174528") 1036 * .setZone("zone3744684") 1037 * .build(); 1038 * OperationFuture<Operation, Operation> future = 1039 * disksClient.insertOperationCallable().futureCall(request); 1040 * // Do something. 1041 * Operation response = future.get(); 1042 * } 1043 * }</pre> 1044 */ 1045 public final OperationCallable<InsertDiskRequest, Operation, Operation> insertOperationCallable()1046 insertOperationCallable() { 1047 return stub.insertOperationCallable(); 1048 } 1049 1050 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1051 /** 1052 * Creates a persistent disk in the specified project using the data in the request. You can 1053 * create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 1054 * GB data disk by omitting all properties. You can also create a disk that is larger than the 1055 * default size by specifying the sizeGb property. 1056 * 1057 * <p>Sample code: 1058 * 1059 * <pre>{@code 1060 * // This snippet has been automatically generated and should be regarded as a code template only. 1061 * // It will require modifications to work: 1062 * // - It may require correct/in-range values for request initialization. 1063 * // - It may require specifying regional endpoints when creating the service client as shown in 1064 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1065 * try (DisksClient disksClient = DisksClient.create()) { 1066 * InsertDiskRequest request = 1067 * InsertDiskRequest.newBuilder() 1068 * .setDiskResource(Disk.newBuilder().build()) 1069 * .setProject("project-309310695") 1070 * .setRequestId("requestId693933066") 1071 * .setSourceImage("sourceImage-105174528") 1072 * .setZone("zone3744684") 1073 * .build(); 1074 * ApiFuture<Operation> future = disksClient.insertCallable().futureCall(request); 1075 * // Do something. 1076 * Operation response = future.get(); 1077 * } 1078 * }</pre> 1079 */ insertCallable()1080 public final UnaryCallable<InsertDiskRequest, Operation> insertCallable() { 1081 return stub.insertCallable(); 1082 } 1083 1084 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1085 /** 1086 * Retrieves a list of persistent disks contained within the specified zone. 1087 * 1088 * <p>Sample code: 1089 * 1090 * <pre>{@code 1091 * // This snippet has been automatically generated and should be regarded as a code template only. 1092 * // It will require modifications to work: 1093 * // - It may require correct/in-range values for request initialization. 1094 * // - It may require specifying regional endpoints when creating the service client as shown in 1095 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1096 * try (DisksClient disksClient = DisksClient.create()) { 1097 * String project = "project-309310695"; 1098 * String zone = "zone3744684"; 1099 * for (Disk element : disksClient.list(project, zone).iterateAll()) { 1100 * // doThingsWith(element); 1101 * } 1102 * } 1103 * }</pre> 1104 * 1105 * @param project Project ID for this request. 1106 * @param zone The name of the zone for this request. 1107 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1108 */ list(String project, String zone)1109 public final ListPagedResponse list(String project, String zone) { 1110 ListDisksRequest request = 1111 ListDisksRequest.newBuilder().setProject(project).setZone(zone).build(); 1112 return list(request); 1113 } 1114 1115 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1116 /** 1117 * Retrieves a list of persistent disks contained within the specified zone. 1118 * 1119 * <p>Sample code: 1120 * 1121 * <pre>{@code 1122 * // This snippet has been automatically generated and should be regarded as a code template only. 1123 * // It will require modifications to work: 1124 * // - It may require correct/in-range values for request initialization. 1125 * // - It may require specifying regional endpoints when creating the service client as shown in 1126 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1127 * try (DisksClient disksClient = DisksClient.create()) { 1128 * ListDisksRequest request = 1129 * ListDisksRequest.newBuilder() 1130 * .setFilter("filter-1274492040") 1131 * .setMaxResults(1128457243) 1132 * .setOrderBy("orderBy-1207110587") 1133 * .setPageToken("pageToken873572522") 1134 * .setProject("project-309310695") 1135 * .setReturnPartialSuccess(true) 1136 * .setZone("zone3744684") 1137 * .build(); 1138 * for (Disk element : disksClient.list(request).iterateAll()) { 1139 * // doThingsWith(element); 1140 * } 1141 * } 1142 * }</pre> 1143 * 1144 * @param request The request object containing all of the parameters for the API call. 1145 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1146 */ list(ListDisksRequest request)1147 public final ListPagedResponse list(ListDisksRequest request) { 1148 return listPagedCallable().call(request); 1149 } 1150 1151 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1152 /** 1153 * Retrieves a list of persistent disks contained within the specified zone. 1154 * 1155 * <p>Sample code: 1156 * 1157 * <pre>{@code 1158 * // This snippet has been automatically generated and should be regarded as a code template only. 1159 * // It will require modifications to work: 1160 * // - It may require correct/in-range values for request initialization. 1161 * // - It may require specifying regional endpoints when creating the service client as shown in 1162 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1163 * try (DisksClient disksClient = DisksClient.create()) { 1164 * ListDisksRequest request = 1165 * ListDisksRequest.newBuilder() 1166 * .setFilter("filter-1274492040") 1167 * .setMaxResults(1128457243) 1168 * .setOrderBy("orderBy-1207110587") 1169 * .setPageToken("pageToken873572522") 1170 * .setProject("project-309310695") 1171 * .setReturnPartialSuccess(true) 1172 * .setZone("zone3744684") 1173 * .build(); 1174 * ApiFuture<Disk> future = disksClient.listPagedCallable().futureCall(request); 1175 * // Do something. 1176 * for (Disk element : future.get().iterateAll()) { 1177 * // doThingsWith(element); 1178 * } 1179 * } 1180 * }</pre> 1181 */ listPagedCallable()1182 public final UnaryCallable<ListDisksRequest, ListPagedResponse> listPagedCallable() { 1183 return stub.listPagedCallable(); 1184 } 1185 1186 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1187 /** 1188 * Retrieves a list of persistent disks contained within the specified zone. 1189 * 1190 * <p>Sample code: 1191 * 1192 * <pre>{@code 1193 * // This snippet has been automatically generated and should be regarded as a code template only. 1194 * // It will require modifications to work: 1195 * // - It may require correct/in-range values for request initialization. 1196 * // - It may require specifying regional endpoints when creating the service client as shown in 1197 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1198 * try (DisksClient disksClient = DisksClient.create()) { 1199 * ListDisksRequest request = 1200 * ListDisksRequest.newBuilder() 1201 * .setFilter("filter-1274492040") 1202 * .setMaxResults(1128457243) 1203 * .setOrderBy("orderBy-1207110587") 1204 * .setPageToken("pageToken873572522") 1205 * .setProject("project-309310695") 1206 * .setReturnPartialSuccess(true) 1207 * .setZone("zone3744684") 1208 * .build(); 1209 * while (true) { 1210 * DiskList response = disksClient.listCallable().call(request); 1211 * for (Disk element : response.getItemsList()) { 1212 * // doThingsWith(element); 1213 * } 1214 * String nextPageToken = response.getNextPageToken(); 1215 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1216 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1217 * } else { 1218 * break; 1219 * } 1220 * } 1221 * } 1222 * }</pre> 1223 */ listCallable()1224 public final UnaryCallable<ListDisksRequest, DiskList> listCallable() { 1225 return stub.listCallable(); 1226 } 1227 1228 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1229 /** 1230 * Removes resource policies from a disk. 1231 * 1232 * <p>Sample code: 1233 * 1234 * <pre>{@code 1235 * // This snippet has been automatically generated and should be regarded as a code template only. 1236 * // It will require modifications to work: 1237 * // - It may require correct/in-range values for request initialization. 1238 * // - It may require specifying regional endpoints when creating the service client as shown in 1239 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1240 * try (DisksClient disksClient = DisksClient.create()) { 1241 * String project = "project-309310695"; 1242 * String zone = "zone3744684"; 1243 * String disk = "disk3083677"; 1244 * DisksRemoveResourcePoliciesRequest disksRemoveResourcePoliciesRequestResource = 1245 * DisksRemoveResourcePoliciesRequest.newBuilder().build(); 1246 * Operation response = 1247 * disksClient 1248 * .removeResourcePoliciesAsync( 1249 * project, zone, disk, disksRemoveResourcePoliciesRequestResource) 1250 * .get(); 1251 * } 1252 * }</pre> 1253 * 1254 * @param project Project ID for this request. 1255 * @param zone The name of the zone for this request. 1256 * @param disk The disk name for this request. 1257 * @param disksRemoveResourcePoliciesRequestResource The body resource for this request 1258 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1259 */ removeResourcePoliciesAsync( String project, String zone, String disk, DisksRemoveResourcePoliciesRequest disksRemoveResourcePoliciesRequestResource)1260 public final OperationFuture<Operation, Operation> removeResourcePoliciesAsync( 1261 String project, 1262 String zone, 1263 String disk, 1264 DisksRemoveResourcePoliciesRequest disksRemoveResourcePoliciesRequestResource) { 1265 RemoveResourcePoliciesDiskRequest request = 1266 RemoveResourcePoliciesDiskRequest.newBuilder() 1267 .setProject(project) 1268 .setZone(zone) 1269 .setDisk(disk) 1270 .setDisksRemoveResourcePoliciesRequestResource( 1271 disksRemoveResourcePoliciesRequestResource) 1272 .build(); 1273 return removeResourcePoliciesAsync(request); 1274 } 1275 1276 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1277 /** 1278 * Removes resource policies from a disk. 1279 * 1280 * <p>Sample code: 1281 * 1282 * <pre>{@code 1283 * // This snippet has been automatically generated and should be regarded as a code template only. 1284 * // It will require modifications to work: 1285 * // - It may require correct/in-range values for request initialization. 1286 * // - It may require specifying regional endpoints when creating the service client as shown in 1287 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1288 * try (DisksClient disksClient = DisksClient.create()) { 1289 * RemoveResourcePoliciesDiskRequest request = 1290 * RemoveResourcePoliciesDiskRequest.newBuilder() 1291 * .setDisk("disk3083677") 1292 * .setDisksRemoveResourcePoliciesRequestResource( 1293 * DisksRemoveResourcePoliciesRequest.newBuilder().build()) 1294 * .setProject("project-309310695") 1295 * .setRequestId("requestId693933066") 1296 * .setZone("zone3744684") 1297 * .build(); 1298 * Operation response = disksClient.removeResourcePoliciesAsync(request).get(); 1299 * } 1300 * }</pre> 1301 * 1302 * @param request The request object containing all of the parameters for the API call. 1303 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1304 */ 1305 @BetaApi( 1306 "The surface for long-running operations is not stable yet and may change in the future.") removeResourcePoliciesAsync( RemoveResourcePoliciesDiskRequest request)1307 public final OperationFuture<Operation, Operation> removeResourcePoliciesAsync( 1308 RemoveResourcePoliciesDiskRequest request) { 1309 return removeResourcePoliciesOperationCallable().futureCall(request); 1310 } 1311 1312 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1313 /** 1314 * Removes resource policies from a disk. 1315 * 1316 * <p>Sample code: 1317 * 1318 * <pre>{@code 1319 * // This snippet has been automatically generated and should be regarded as a code template only. 1320 * // It will require modifications to work: 1321 * // - It may require correct/in-range values for request initialization. 1322 * // - It may require specifying regional endpoints when creating the service client as shown in 1323 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1324 * try (DisksClient disksClient = DisksClient.create()) { 1325 * RemoveResourcePoliciesDiskRequest request = 1326 * RemoveResourcePoliciesDiskRequest.newBuilder() 1327 * .setDisk("disk3083677") 1328 * .setDisksRemoveResourcePoliciesRequestResource( 1329 * DisksRemoveResourcePoliciesRequest.newBuilder().build()) 1330 * .setProject("project-309310695") 1331 * .setRequestId("requestId693933066") 1332 * .setZone("zone3744684") 1333 * .build(); 1334 * OperationFuture<Operation, Operation> future = 1335 * disksClient.removeResourcePoliciesOperationCallable().futureCall(request); 1336 * // Do something. 1337 * Operation response = future.get(); 1338 * } 1339 * }</pre> 1340 */ 1341 public final OperationCallable<RemoveResourcePoliciesDiskRequest, Operation, Operation> removeResourcePoliciesOperationCallable()1342 removeResourcePoliciesOperationCallable() { 1343 return stub.removeResourcePoliciesOperationCallable(); 1344 } 1345 1346 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1347 /** 1348 * Removes resource policies from a disk. 1349 * 1350 * <p>Sample code: 1351 * 1352 * <pre>{@code 1353 * // This snippet has been automatically generated and should be regarded as a code template only. 1354 * // It will require modifications to work: 1355 * // - It may require correct/in-range values for request initialization. 1356 * // - It may require specifying regional endpoints when creating the service client as shown in 1357 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1358 * try (DisksClient disksClient = DisksClient.create()) { 1359 * RemoveResourcePoliciesDiskRequest request = 1360 * RemoveResourcePoliciesDiskRequest.newBuilder() 1361 * .setDisk("disk3083677") 1362 * .setDisksRemoveResourcePoliciesRequestResource( 1363 * DisksRemoveResourcePoliciesRequest.newBuilder().build()) 1364 * .setProject("project-309310695") 1365 * .setRequestId("requestId693933066") 1366 * .setZone("zone3744684") 1367 * .build(); 1368 * ApiFuture<Operation> future = 1369 * disksClient.removeResourcePoliciesCallable().futureCall(request); 1370 * // Do something. 1371 * Operation response = future.get(); 1372 * } 1373 * }</pre> 1374 */ 1375 public final UnaryCallable<RemoveResourcePoliciesDiskRequest, Operation> removeResourcePoliciesCallable()1376 removeResourcePoliciesCallable() { 1377 return stub.removeResourcePoliciesCallable(); 1378 } 1379 1380 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1381 /** 1382 * Resizes the specified persistent disk. You can only increase the size of the disk. 1383 * 1384 * <p>Sample code: 1385 * 1386 * <pre>{@code 1387 * // This snippet has been automatically generated and should be regarded as a code template only. 1388 * // It will require modifications to work: 1389 * // - It may require correct/in-range values for request initialization. 1390 * // - It may require specifying regional endpoints when creating the service client as shown in 1391 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1392 * try (DisksClient disksClient = DisksClient.create()) { 1393 * String project = "project-309310695"; 1394 * String zone = "zone3744684"; 1395 * String disk = "disk3083677"; 1396 * DisksResizeRequest disksResizeRequestResource = DisksResizeRequest.newBuilder().build(); 1397 * Operation response = 1398 * disksClient.resizeAsync(project, zone, disk, disksResizeRequestResource).get(); 1399 * } 1400 * }</pre> 1401 * 1402 * @param project Project ID for this request. 1403 * @param zone The name of the zone for this request. 1404 * @param disk The name of the persistent disk. 1405 * @param disksResizeRequestResource The body resource for this request 1406 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1407 */ resizeAsync( String project, String zone, String disk, DisksResizeRequest disksResizeRequestResource)1408 public final OperationFuture<Operation, Operation> resizeAsync( 1409 String project, String zone, String disk, DisksResizeRequest disksResizeRequestResource) { 1410 ResizeDiskRequest request = 1411 ResizeDiskRequest.newBuilder() 1412 .setProject(project) 1413 .setZone(zone) 1414 .setDisk(disk) 1415 .setDisksResizeRequestResource(disksResizeRequestResource) 1416 .build(); 1417 return resizeAsync(request); 1418 } 1419 1420 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1421 /** 1422 * Resizes the specified persistent disk. You can only increase the size of the disk. 1423 * 1424 * <p>Sample code: 1425 * 1426 * <pre>{@code 1427 * // This snippet has been automatically generated and should be regarded as a code template only. 1428 * // It will require modifications to work: 1429 * // - It may require correct/in-range values for request initialization. 1430 * // - It may require specifying regional endpoints when creating the service client as shown in 1431 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1432 * try (DisksClient disksClient = DisksClient.create()) { 1433 * ResizeDiskRequest request = 1434 * ResizeDiskRequest.newBuilder() 1435 * .setDisk("disk3083677") 1436 * .setDisksResizeRequestResource(DisksResizeRequest.newBuilder().build()) 1437 * .setProject("project-309310695") 1438 * .setRequestId("requestId693933066") 1439 * .setZone("zone3744684") 1440 * .build(); 1441 * Operation response = disksClient.resizeAsync(request).get(); 1442 * } 1443 * }</pre> 1444 * 1445 * @param request The request object containing all of the parameters for the API call. 1446 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1447 */ 1448 @BetaApi( 1449 "The surface for long-running operations is not stable yet and may change in the future.") resizeAsync(ResizeDiskRequest request)1450 public final OperationFuture<Operation, Operation> resizeAsync(ResizeDiskRequest request) { 1451 return resizeOperationCallable().futureCall(request); 1452 } 1453 1454 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1455 /** 1456 * Resizes the specified persistent disk. You can only increase the size of the disk. 1457 * 1458 * <p>Sample code: 1459 * 1460 * <pre>{@code 1461 * // This snippet has been automatically generated and should be regarded as a code template only. 1462 * // It will require modifications to work: 1463 * // - It may require correct/in-range values for request initialization. 1464 * // - It may require specifying regional endpoints when creating the service client as shown in 1465 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1466 * try (DisksClient disksClient = DisksClient.create()) { 1467 * ResizeDiskRequest request = 1468 * ResizeDiskRequest.newBuilder() 1469 * .setDisk("disk3083677") 1470 * .setDisksResizeRequestResource(DisksResizeRequest.newBuilder().build()) 1471 * .setProject("project-309310695") 1472 * .setRequestId("requestId693933066") 1473 * .setZone("zone3744684") 1474 * .build(); 1475 * OperationFuture<Operation, Operation> future = 1476 * disksClient.resizeOperationCallable().futureCall(request); 1477 * // Do something. 1478 * Operation response = future.get(); 1479 * } 1480 * }</pre> 1481 */ 1482 public final OperationCallable<ResizeDiskRequest, Operation, Operation> resizeOperationCallable()1483 resizeOperationCallable() { 1484 return stub.resizeOperationCallable(); 1485 } 1486 1487 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1488 /** 1489 * Resizes the specified persistent disk. You can only increase the size of the disk. 1490 * 1491 * <p>Sample code: 1492 * 1493 * <pre>{@code 1494 * // This snippet has been automatically generated and should be regarded as a code template only. 1495 * // It will require modifications to work: 1496 * // - It may require correct/in-range values for request initialization. 1497 * // - It may require specifying regional endpoints when creating the service client as shown in 1498 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1499 * try (DisksClient disksClient = DisksClient.create()) { 1500 * ResizeDiskRequest request = 1501 * ResizeDiskRequest.newBuilder() 1502 * .setDisk("disk3083677") 1503 * .setDisksResizeRequestResource(DisksResizeRequest.newBuilder().build()) 1504 * .setProject("project-309310695") 1505 * .setRequestId("requestId693933066") 1506 * .setZone("zone3744684") 1507 * .build(); 1508 * ApiFuture<Operation> future = disksClient.resizeCallable().futureCall(request); 1509 * // Do something. 1510 * Operation response = future.get(); 1511 * } 1512 * }</pre> 1513 */ resizeCallable()1514 public final UnaryCallable<ResizeDiskRequest, Operation> resizeCallable() { 1515 return stub.resizeCallable(); 1516 } 1517 1518 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1519 /** 1520 * Sets the access control policy on the specified resource. Replaces any existing policy. 1521 * 1522 * <p>Sample code: 1523 * 1524 * <pre>{@code 1525 * // This snippet has been automatically generated and should be regarded as a code template only. 1526 * // It will require modifications to work: 1527 * // - It may require correct/in-range values for request initialization. 1528 * // - It may require specifying regional endpoints when creating the service client as shown in 1529 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1530 * try (DisksClient disksClient = DisksClient.create()) { 1531 * String project = "project-309310695"; 1532 * String zone = "zone3744684"; 1533 * String resource = "resource-341064690"; 1534 * ZoneSetPolicyRequest zoneSetPolicyRequestResource = ZoneSetPolicyRequest.newBuilder().build(); 1535 * Policy response = 1536 * disksClient.setIamPolicy(project, zone, resource, zoneSetPolicyRequestResource); 1537 * } 1538 * }</pre> 1539 * 1540 * @param project Project ID for this request. 1541 * @param zone The name of the zone for this request. 1542 * @param resource Name or id of the resource for this request. 1543 * @param zoneSetPolicyRequestResource The body resource for this request 1544 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1545 */ setIamPolicy( String project, String zone, String resource, ZoneSetPolicyRequest zoneSetPolicyRequestResource)1546 public final Policy setIamPolicy( 1547 String project, 1548 String zone, 1549 String resource, 1550 ZoneSetPolicyRequest zoneSetPolicyRequestResource) { 1551 SetIamPolicyDiskRequest request = 1552 SetIamPolicyDiskRequest.newBuilder() 1553 .setProject(project) 1554 .setZone(zone) 1555 .setResource(resource) 1556 .setZoneSetPolicyRequestResource(zoneSetPolicyRequestResource) 1557 .build(); 1558 return setIamPolicy(request); 1559 } 1560 1561 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1562 /** 1563 * Sets the access control policy on the specified resource. Replaces any existing policy. 1564 * 1565 * <p>Sample code: 1566 * 1567 * <pre>{@code 1568 * // This snippet has been automatically generated and should be regarded as a code template only. 1569 * // It will require modifications to work: 1570 * // - It may require correct/in-range values for request initialization. 1571 * // - It may require specifying regional endpoints when creating the service client as shown in 1572 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1573 * try (DisksClient disksClient = DisksClient.create()) { 1574 * SetIamPolicyDiskRequest request = 1575 * SetIamPolicyDiskRequest.newBuilder() 1576 * .setProject("project-309310695") 1577 * .setResource("resource-341064690") 1578 * .setZone("zone3744684") 1579 * .setZoneSetPolicyRequestResource(ZoneSetPolicyRequest.newBuilder().build()) 1580 * .build(); 1581 * Policy response = disksClient.setIamPolicy(request); 1582 * } 1583 * }</pre> 1584 * 1585 * @param request The request object containing all of the parameters for the API call. 1586 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1587 */ setIamPolicy(SetIamPolicyDiskRequest request)1588 public final Policy setIamPolicy(SetIamPolicyDiskRequest request) { 1589 return setIamPolicyCallable().call(request); 1590 } 1591 1592 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1593 /** 1594 * Sets the access control policy on the specified resource. Replaces any existing policy. 1595 * 1596 * <p>Sample code: 1597 * 1598 * <pre>{@code 1599 * // This snippet has been automatically generated and should be regarded as a code template only. 1600 * // It will require modifications to work: 1601 * // - It may require correct/in-range values for request initialization. 1602 * // - It may require specifying regional endpoints when creating the service client as shown in 1603 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1604 * try (DisksClient disksClient = DisksClient.create()) { 1605 * SetIamPolicyDiskRequest request = 1606 * SetIamPolicyDiskRequest.newBuilder() 1607 * .setProject("project-309310695") 1608 * .setResource("resource-341064690") 1609 * .setZone("zone3744684") 1610 * .setZoneSetPolicyRequestResource(ZoneSetPolicyRequest.newBuilder().build()) 1611 * .build(); 1612 * ApiFuture<Policy> future = disksClient.setIamPolicyCallable().futureCall(request); 1613 * // Do something. 1614 * Policy response = future.get(); 1615 * } 1616 * }</pre> 1617 */ setIamPolicyCallable()1618 public final UnaryCallable<SetIamPolicyDiskRequest, Policy> setIamPolicyCallable() { 1619 return stub.setIamPolicyCallable(); 1620 } 1621 1622 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1623 /** 1624 * Sets the labels on a disk. To learn more about labels, read the Labeling Resources 1625 * documentation. 1626 * 1627 * <p>Sample code: 1628 * 1629 * <pre>{@code 1630 * // This snippet has been automatically generated and should be regarded as a code template only. 1631 * // It will require modifications to work: 1632 * // - It may require correct/in-range values for request initialization. 1633 * // - It may require specifying regional endpoints when creating the service client as shown in 1634 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1635 * try (DisksClient disksClient = DisksClient.create()) { 1636 * String project = "project-309310695"; 1637 * String zone = "zone3744684"; 1638 * String resource = "resource-341064690"; 1639 * ZoneSetLabelsRequest zoneSetLabelsRequestResource = ZoneSetLabelsRequest.newBuilder().build(); 1640 * Operation response = 1641 * disksClient.setLabelsAsync(project, zone, resource, zoneSetLabelsRequestResource).get(); 1642 * } 1643 * }</pre> 1644 * 1645 * @param project Project ID for this request. 1646 * @param zone The name of the zone for this request. 1647 * @param resource Name or id of the resource for this request. 1648 * @param zoneSetLabelsRequestResource The body resource for this request 1649 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1650 */ setLabelsAsync( String project, String zone, String resource, ZoneSetLabelsRequest zoneSetLabelsRequestResource)1651 public final OperationFuture<Operation, Operation> setLabelsAsync( 1652 String project, 1653 String zone, 1654 String resource, 1655 ZoneSetLabelsRequest zoneSetLabelsRequestResource) { 1656 SetLabelsDiskRequest request = 1657 SetLabelsDiskRequest.newBuilder() 1658 .setProject(project) 1659 .setZone(zone) 1660 .setResource(resource) 1661 .setZoneSetLabelsRequestResource(zoneSetLabelsRequestResource) 1662 .build(); 1663 return setLabelsAsync(request); 1664 } 1665 1666 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1667 /** 1668 * Sets the labels on a disk. To learn more about labels, read the Labeling Resources 1669 * documentation. 1670 * 1671 * <p>Sample code: 1672 * 1673 * <pre>{@code 1674 * // This snippet has been automatically generated and should be regarded as a code template only. 1675 * // It will require modifications to work: 1676 * // - It may require correct/in-range values for request initialization. 1677 * // - It may require specifying regional endpoints when creating the service client as shown in 1678 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1679 * try (DisksClient disksClient = DisksClient.create()) { 1680 * SetLabelsDiskRequest request = 1681 * SetLabelsDiskRequest.newBuilder() 1682 * .setProject("project-309310695") 1683 * .setRequestId("requestId693933066") 1684 * .setResource("resource-341064690") 1685 * .setZone("zone3744684") 1686 * .setZoneSetLabelsRequestResource(ZoneSetLabelsRequest.newBuilder().build()) 1687 * .build(); 1688 * Operation response = disksClient.setLabelsAsync(request).get(); 1689 * } 1690 * }</pre> 1691 * 1692 * @param request The request object containing all of the parameters for the API call. 1693 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1694 */ 1695 @BetaApi( 1696 "The surface for long-running operations is not stable yet and may change in the future.") setLabelsAsync(SetLabelsDiskRequest request)1697 public final OperationFuture<Operation, Operation> setLabelsAsync(SetLabelsDiskRequest request) { 1698 return setLabelsOperationCallable().futureCall(request); 1699 } 1700 1701 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1702 /** 1703 * Sets the labels on a disk. To learn more about labels, read the Labeling Resources 1704 * documentation. 1705 * 1706 * <p>Sample code: 1707 * 1708 * <pre>{@code 1709 * // This snippet has been automatically generated and should be regarded as a code template only. 1710 * // It will require modifications to work: 1711 * // - It may require correct/in-range values for request initialization. 1712 * // - It may require specifying regional endpoints when creating the service client as shown in 1713 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1714 * try (DisksClient disksClient = DisksClient.create()) { 1715 * SetLabelsDiskRequest request = 1716 * SetLabelsDiskRequest.newBuilder() 1717 * .setProject("project-309310695") 1718 * .setRequestId("requestId693933066") 1719 * .setResource("resource-341064690") 1720 * .setZone("zone3744684") 1721 * .setZoneSetLabelsRequestResource(ZoneSetLabelsRequest.newBuilder().build()) 1722 * .build(); 1723 * OperationFuture<Operation, Operation> future = 1724 * disksClient.setLabelsOperationCallable().futureCall(request); 1725 * // Do something. 1726 * Operation response = future.get(); 1727 * } 1728 * }</pre> 1729 */ 1730 public final OperationCallable<SetLabelsDiskRequest, Operation, Operation> setLabelsOperationCallable()1731 setLabelsOperationCallable() { 1732 return stub.setLabelsOperationCallable(); 1733 } 1734 1735 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1736 /** 1737 * Sets the labels on a disk. To learn more about labels, read the Labeling Resources 1738 * documentation. 1739 * 1740 * <p>Sample code: 1741 * 1742 * <pre>{@code 1743 * // This snippet has been automatically generated and should be regarded as a code template only. 1744 * // It will require modifications to work: 1745 * // - It may require correct/in-range values for request initialization. 1746 * // - It may require specifying regional endpoints when creating the service client as shown in 1747 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1748 * try (DisksClient disksClient = DisksClient.create()) { 1749 * SetLabelsDiskRequest request = 1750 * SetLabelsDiskRequest.newBuilder() 1751 * .setProject("project-309310695") 1752 * .setRequestId("requestId693933066") 1753 * .setResource("resource-341064690") 1754 * .setZone("zone3744684") 1755 * .setZoneSetLabelsRequestResource(ZoneSetLabelsRequest.newBuilder().build()) 1756 * .build(); 1757 * ApiFuture<Operation> future = disksClient.setLabelsCallable().futureCall(request); 1758 * // Do something. 1759 * Operation response = future.get(); 1760 * } 1761 * }</pre> 1762 */ setLabelsCallable()1763 public final UnaryCallable<SetLabelsDiskRequest, Operation> setLabelsCallable() { 1764 return stub.setLabelsCallable(); 1765 } 1766 1767 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1768 /** 1769 * Returns permissions that a caller has on the specified resource. 1770 * 1771 * <p>Sample code: 1772 * 1773 * <pre>{@code 1774 * // This snippet has been automatically generated and should be regarded as a code template only. 1775 * // It will require modifications to work: 1776 * // - It may require correct/in-range values for request initialization. 1777 * // - It may require specifying regional endpoints when creating the service client as shown in 1778 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1779 * try (DisksClient disksClient = DisksClient.create()) { 1780 * String project = "project-309310695"; 1781 * String zone = "zone3744684"; 1782 * String resource = "resource-341064690"; 1783 * TestPermissionsRequest testPermissionsRequestResource = 1784 * TestPermissionsRequest.newBuilder().build(); 1785 * TestPermissionsResponse response = 1786 * disksClient.testIamPermissions(project, zone, resource, testPermissionsRequestResource); 1787 * } 1788 * }</pre> 1789 * 1790 * @param project Project ID for this request. 1791 * @param zone The name of the zone for this request. 1792 * @param resource Name or id of the resource for this request. 1793 * @param testPermissionsRequestResource The body resource for this request 1794 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1795 */ testIamPermissions( String project, String zone, String resource, TestPermissionsRequest testPermissionsRequestResource)1796 public final TestPermissionsResponse testIamPermissions( 1797 String project, 1798 String zone, 1799 String resource, 1800 TestPermissionsRequest testPermissionsRequestResource) { 1801 TestIamPermissionsDiskRequest request = 1802 TestIamPermissionsDiskRequest.newBuilder() 1803 .setProject(project) 1804 .setZone(zone) 1805 .setResource(resource) 1806 .setTestPermissionsRequestResource(testPermissionsRequestResource) 1807 .build(); 1808 return testIamPermissions(request); 1809 } 1810 1811 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1812 /** 1813 * Returns permissions that a caller has on the specified resource. 1814 * 1815 * <p>Sample code: 1816 * 1817 * <pre>{@code 1818 * // This snippet has been automatically generated and should be regarded as a code template only. 1819 * // It will require modifications to work: 1820 * // - It may require correct/in-range values for request initialization. 1821 * // - It may require specifying regional endpoints when creating the service client as shown in 1822 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1823 * try (DisksClient disksClient = DisksClient.create()) { 1824 * TestIamPermissionsDiskRequest request = 1825 * TestIamPermissionsDiskRequest.newBuilder() 1826 * .setProject("project-309310695") 1827 * .setResource("resource-341064690") 1828 * .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build()) 1829 * .setZone("zone3744684") 1830 * .build(); 1831 * TestPermissionsResponse response = disksClient.testIamPermissions(request); 1832 * } 1833 * }</pre> 1834 * 1835 * @param request The request object containing all of the parameters for the API call. 1836 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1837 */ testIamPermissions(TestIamPermissionsDiskRequest request)1838 public final TestPermissionsResponse testIamPermissions(TestIamPermissionsDiskRequest request) { 1839 return testIamPermissionsCallable().call(request); 1840 } 1841 1842 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1843 /** 1844 * Returns permissions that a caller has on the specified resource. 1845 * 1846 * <p>Sample code: 1847 * 1848 * <pre>{@code 1849 * // This snippet has been automatically generated and should be regarded as a code template only. 1850 * // It will require modifications to work: 1851 * // - It may require correct/in-range values for request initialization. 1852 * // - It may require specifying regional endpoints when creating the service client as shown in 1853 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1854 * try (DisksClient disksClient = DisksClient.create()) { 1855 * TestIamPermissionsDiskRequest request = 1856 * TestIamPermissionsDiskRequest.newBuilder() 1857 * .setProject("project-309310695") 1858 * .setResource("resource-341064690") 1859 * .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build()) 1860 * .setZone("zone3744684") 1861 * .build(); 1862 * ApiFuture<TestPermissionsResponse> future = 1863 * disksClient.testIamPermissionsCallable().futureCall(request); 1864 * // Do something. 1865 * TestPermissionsResponse response = future.get(); 1866 * } 1867 * }</pre> 1868 */ 1869 public final UnaryCallable<TestIamPermissionsDiskRequest, TestPermissionsResponse> testIamPermissionsCallable()1870 testIamPermissionsCallable() { 1871 return stub.testIamPermissionsCallable(); 1872 } 1873 1874 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1875 /** 1876 * Updates the specified disk with the data included in the request. The update is performed only 1877 * on selected fields included as part of update-mask. Only the following fields can be modified: 1878 * user_license. 1879 * 1880 * <p>Sample code: 1881 * 1882 * <pre>{@code 1883 * // This snippet has been automatically generated and should be regarded as a code template only. 1884 * // It will require modifications to work: 1885 * // - It may require correct/in-range values for request initialization. 1886 * // - It may require specifying regional endpoints when creating the service client as shown in 1887 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1888 * try (DisksClient disksClient = DisksClient.create()) { 1889 * String project = "project-309310695"; 1890 * String zone = "zone3744684"; 1891 * String disk = "disk3083677"; 1892 * Disk diskResource = Disk.newBuilder().build(); 1893 * Operation response = disksClient.updateAsync(project, zone, disk, diskResource).get(); 1894 * } 1895 * }</pre> 1896 * 1897 * @param project Project ID for this request. 1898 * @param zone The name of the zone for this request. 1899 * @param disk The disk name for this request. 1900 * @param diskResource The body resource for this request 1901 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1902 */ updateAsync( String project, String zone, String disk, Disk diskResource)1903 public final OperationFuture<Operation, Operation> updateAsync( 1904 String project, String zone, String disk, Disk diskResource) { 1905 UpdateDiskRequest request = 1906 UpdateDiskRequest.newBuilder() 1907 .setProject(project) 1908 .setZone(zone) 1909 .setDisk(disk) 1910 .setDiskResource(diskResource) 1911 .build(); 1912 return updateAsync(request); 1913 } 1914 1915 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1916 /** 1917 * Updates the specified disk with the data included in the request. The update is performed only 1918 * on selected fields included as part of update-mask. Only the following fields can be modified: 1919 * user_license. 1920 * 1921 * <p>Sample code: 1922 * 1923 * <pre>{@code 1924 * // This snippet has been automatically generated and should be regarded as a code template only. 1925 * // It will require modifications to work: 1926 * // - It may require correct/in-range values for request initialization. 1927 * // - It may require specifying regional endpoints when creating the service client as shown in 1928 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1929 * try (DisksClient disksClient = DisksClient.create()) { 1930 * UpdateDiskRequest request = 1931 * UpdateDiskRequest.newBuilder() 1932 * .setDisk("disk3083677") 1933 * .setDiskResource(Disk.newBuilder().build()) 1934 * .setPaths("paths106438894") 1935 * .setProject("project-309310695") 1936 * .setRequestId("requestId693933066") 1937 * .setUpdateMask("updateMask-296147115") 1938 * .setZone("zone3744684") 1939 * .build(); 1940 * Operation response = disksClient.updateAsync(request).get(); 1941 * } 1942 * }</pre> 1943 * 1944 * @param request The request object containing all of the parameters for the API call. 1945 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1946 */ 1947 @BetaApi( 1948 "The surface for long-running operations is not stable yet and may change in the future.") updateAsync(UpdateDiskRequest request)1949 public final OperationFuture<Operation, Operation> updateAsync(UpdateDiskRequest request) { 1950 return updateOperationCallable().futureCall(request); 1951 } 1952 1953 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1954 /** 1955 * Updates the specified disk with the data included in the request. The update is performed only 1956 * on selected fields included as part of update-mask. Only the following fields can be modified: 1957 * user_license. 1958 * 1959 * <p>Sample code: 1960 * 1961 * <pre>{@code 1962 * // This snippet has been automatically generated and should be regarded as a code template only. 1963 * // It will require modifications to work: 1964 * // - It may require correct/in-range values for request initialization. 1965 * // - It may require specifying regional endpoints when creating the service client as shown in 1966 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1967 * try (DisksClient disksClient = DisksClient.create()) { 1968 * UpdateDiskRequest request = 1969 * UpdateDiskRequest.newBuilder() 1970 * .setDisk("disk3083677") 1971 * .setDiskResource(Disk.newBuilder().build()) 1972 * .setPaths("paths106438894") 1973 * .setProject("project-309310695") 1974 * .setRequestId("requestId693933066") 1975 * .setUpdateMask("updateMask-296147115") 1976 * .setZone("zone3744684") 1977 * .build(); 1978 * OperationFuture<Operation, Operation> future = 1979 * disksClient.updateOperationCallable().futureCall(request); 1980 * // Do something. 1981 * Operation response = future.get(); 1982 * } 1983 * }</pre> 1984 */ 1985 public final OperationCallable<UpdateDiskRequest, Operation, Operation> updateOperationCallable()1986 updateOperationCallable() { 1987 return stub.updateOperationCallable(); 1988 } 1989 1990 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1991 /** 1992 * Updates the specified disk with the data included in the request. The update is performed only 1993 * on selected fields included as part of update-mask. Only the following fields can be modified: 1994 * user_license. 1995 * 1996 * <p>Sample code: 1997 * 1998 * <pre>{@code 1999 * // This snippet has been automatically generated and should be regarded as a code template only. 2000 * // It will require modifications to work: 2001 * // - It may require correct/in-range values for request initialization. 2002 * // - It may require specifying regional endpoints when creating the service client as shown in 2003 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2004 * try (DisksClient disksClient = DisksClient.create()) { 2005 * UpdateDiskRequest request = 2006 * UpdateDiskRequest.newBuilder() 2007 * .setDisk("disk3083677") 2008 * .setDiskResource(Disk.newBuilder().build()) 2009 * .setPaths("paths106438894") 2010 * .setProject("project-309310695") 2011 * .setRequestId("requestId693933066") 2012 * .setUpdateMask("updateMask-296147115") 2013 * .setZone("zone3744684") 2014 * .build(); 2015 * ApiFuture<Operation> future = disksClient.updateCallable().futureCall(request); 2016 * // Do something. 2017 * Operation response = future.get(); 2018 * } 2019 * }</pre> 2020 */ updateCallable()2021 public final UnaryCallable<UpdateDiskRequest, Operation> updateCallable() { 2022 return stub.updateCallable(); 2023 } 2024 2025 @Override close()2026 public final void close() { 2027 stub.close(); 2028 } 2029 2030 @Override shutdown()2031 public void shutdown() { 2032 stub.shutdown(); 2033 } 2034 2035 @Override isShutdown()2036 public boolean isShutdown() { 2037 return stub.isShutdown(); 2038 } 2039 2040 @Override isTerminated()2041 public boolean isTerminated() { 2042 return stub.isTerminated(); 2043 } 2044 2045 @Override shutdownNow()2046 public void shutdownNow() { 2047 stub.shutdownNow(); 2048 } 2049 2050 @Override awaitTermination(long duration, TimeUnit unit)2051 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 2052 return stub.awaitTermination(duration, unit); 2053 } 2054 2055 public static class AggregatedListPagedResponse 2056 extends AbstractPagedListResponse< 2057 AggregatedListDisksRequest, 2058 DiskAggregatedList, 2059 Map.Entry<String, DisksScopedList>, 2060 AggregatedListPage, 2061 AggregatedListFixedSizeCollection> { 2062 createAsync( PageContext< AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>> context, ApiFuture<DiskAggregatedList> futureResponse)2063 public static ApiFuture<AggregatedListPagedResponse> createAsync( 2064 PageContext< 2065 AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>> 2066 context, 2067 ApiFuture<DiskAggregatedList> futureResponse) { 2068 ApiFuture<AggregatedListPage> futurePage = 2069 AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse); 2070 return ApiFutures.transform( 2071 futurePage, 2072 input -> new AggregatedListPagedResponse(input), 2073 MoreExecutors.directExecutor()); 2074 } 2075 AggregatedListPagedResponse(AggregatedListPage page)2076 private AggregatedListPagedResponse(AggregatedListPage page) { 2077 super(page, AggregatedListFixedSizeCollection.createEmptyCollection()); 2078 } 2079 } 2080 2081 public static class AggregatedListPage 2082 extends AbstractPage< 2083 AggregatedListDisksRequest, 2084 DiskAggregatedList, 2085 Map.Entry<String, DisksScopedList>, 2086 AggregatedListPage> { 2087 AggregatedListPage( PageContext< AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>> context, DiskAggregatedList response)2088 private AggregatedListPage( 2089 PageContext< 2090 AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>> 2091 context, 2092 DiskAggregatedList response) { 2093 super(context, response); 2094 } 2095 createEmptyPage()2096 private static AggregatedListPage createEmptyPage() { 2097 return new AggregatedListPage(null, null); 2098 } 2099 2100 @Override createPage( PageContext< AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>> context, DiskAggregatedList response)2101 protected AggregatedListPage createPage( 2102 PageContext< 2103 AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>> 2104 context, 2105 DiskAggregatedList response) { 2106 return new AggregatedListPage(context, response); 2107 } 2108 2109 @Override createPageAsync( PageContext< AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>> context, ApiFuture<DiskAggregatedList> futureResponse)2110 public ApiFuture<AggregatedListPage> createPageAsync( 2111 PageContext< 2112 AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>> 2113 context, 2114 ApiFuture<DiskAggregatedList> futureResponse) { 2115 return super.createPageAsync(context, futureResponse); 2116 } 2117 } 2118 2119 public static class AggregatedListFixedSizeCollection 2120 extends AbstractFixedSizeCollection< 2121 AggregatedListDisksRequest, 2122 DiskAggregatedList, 2123 Map.Entry<String, DisksScopedList>, 2124 AggregatedListPage, 2125 AggregatedListFixedSizeCollection> { 2126 AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize)2127 private AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize) { 2128 super(pages, collectionSize); 2129 } 2130 createEmptyCollection()2131 private static AggregatedListFixedSizeCollection createEmptyCollection() { 2132 return new AggregatedListFixedSizeCollection(null, 0); 2133 } 2134 2135 @Override createCollection( List<AggregatedListPage> pages, int collectionSize)2136 protected AggregatedListFixedSizeCollection createCollection( 2137 List<AggregatedListPage> pages, int collectionSize) { 2138 return new AggregatedListFixedSizeCollection(pages, collectionSize); 2139 } 2140 } 2141 2142 public static class ListPagedResponse 2143 extends AbstractPagedListResponse< 2144 ListDisksRequest, DiskList, Disk, ListPage, ListFixedSizeCollection> { 2145 createAsync( PageContext<ListDisksRequest, DiskList, Disk> context, ApiFuture<DiskList> futureResponse)2146 public static ApiFuture<ListPagedResponse> createAsync( 2147 PageContext<ListDisksRequest, DiskList, Disk> context, ApiFuture<DiskList> futureResponse) { 2148 ApiFuture<ListPage> futurePage = 2149 ListPage.createEmptyPage().createPageAsync(context, futureResponse); 2150 return ApiFutures.transform( 2151 futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor()); 2152 } 2153 ListPagedResponse(ListPage page)2154 private ListPagedResponse(ListPage page) { 2155 super(page, ListFixedSizeCollection.createEmptyCollection()); 2156 } 2157 } 2158 2159 public static class ListPage extends AbstractPage<ListDisksRequest, DiskList, Disk, ListPage> { 2160 ListPage(PageContext<ListDisksRequest, DiskList, Disk> context, DiskList response)2161 private ListPage(PageContext<ListDisksRequest, DiskList, Disk> context, DiskList response) { 2162 super(context, response); 2163 } 2164 createEmptyPage()2165 private static ListPage createEmptyPage() { 2166 return new ListPage(null, null); 2167 } 2168 2169 @Override createPage( PageContext<ListDisksRequest, DiskList, Disk> context, DiskList response)2170 protected ListPage createPage( 2171 PageContext<ListDisksRequest, DiskList, Disk> context, DiskList response) { 2172 return new ListPage(context, response); 2173 } 2174 2175 @Override createPageAsync( PageContext<ListDisksRequest, DiskList, Disk> context, ApiFuture<DiskList> futureResponse)2176 public ApiFuture<ListPage> createPageAsync( 2177 PageContext<ListDisksRequest, DiskList, Disk> context, ApiFuture<DiskList> futureResponse) { 2178 return super.createPageAsync(context, futureResponse); 2179 } 2180 } 2181 2182 public static class ListFixedSizeCollection 2183 extends AbstractFixedSizeCollection< 2184 ListDisksRequest, DiskList, Disk, ListPage, ListFixedSizeCollection> { 2185 ListFixedSizeCollection(List<ListPage> pages, int collectionSize)2186 private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) { 2187 super(pages, collectionSize); 2188 } 2189 createEmptyCollection()2190 private static ListFixedSizeCollection createEmptyCollection() { 2191 return new ListFixedSizeCollection(null, 0); 2192 } 2193 2194 @Override createCollection(List<ListPage> pages, int collectionSize)2195 protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) { 2196 return new ListFixedSizeCollection(pages, collectionSize); 2197 } 2198 } 2199 } 2200