DisksClient.java
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.compute.v1;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.compute.v1.stub.DisksStub;
import com.google.cloud.compute.v1.stub.DisksStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: The Disks API.
*
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String disk = "disk3083677";
* Disk response = disksClient.get(project, zone, disk);
* }
* }</pre>
*
* <p>Note: close() needs to be called on the DisksClient object to clean up resources such as
* threads. In the example above, try-with-resources is used, which automatically calls close().
*
* <p>The surface of this class includes several types of Java methods for each of the API's
* methods:
*
* <ol>
* <li>A "flattened" method. With this type of method, the fields of the request type have been
* converted into function parameters. It may be the case that not all fields are available as
* parameters, and not every API method will have a flattened method entry point.
* <li>A "request object" method. This type of method only takes one parameter, a request object,
* which must be constructed before the call. Not every API method will have a request object
* method.
* <li>A "callable" method. This type of method takes no parameters and returns an immutable API
* callable object, which can be used to initiate calls to the service.
* </ol>
*
* <p>See the individual methods for example code.
*
* <p>Many parameters require resource names to be formatted in a particular way. To assist with
* these names, this class includes a format method for each type of name, and additionally a parse
* method to extract the individual identifiers contained within names that are returned.
*
* <p>This class can be customized by passing in a custom instance of DisksSettings to create(). For
* example:
*
* <p>To customize credentials:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* DisksSettings disksSettings =
* DisksSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* DisksClient disksClient = DisksClient.create(disksSettings);
* }</pre>
*
* <p>To customize the endpoint:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* DisksSettings disksSettings = DisksSettings.newBuilder().setEndpoint(myEndpoint).build();
* DisksClient disksClient = DisksClient.create(disksSettings);
* }</pre>
*
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class DisksClient implements BackgroundResource {
private final DisksSettings settings;
private final DisksStub stub;
/** Constructs an instance of DisksClient with default settings. */
public static final DisksClient create() throws IOException {
return create(DisksSettings.newBuilder().build());
}
/**
* Constructs an instance of DisksClient, using the given settings. The channels are created based
* on the settings passed in, or defaults for any settings that are not set.
*/
public static final DisksClient create(DisksSettings settings) throws IOException {
return new DisksClient(settings);
}
/**
* Constructs an instance of DisksClient, using the given stub for making calls. This is for
* advanced usage - prefer using create(DisksSettings).
*/
public static final DisksClient create(DisksStub stub) {
return new DisksClient(stub);
}
/**
* Constructs an instance of DisksClient, using the given settings. This is protected so that it
* is easy to make a subclass, but otherwise, the static factory methods should be preferred.
*/
protected DisksClient(DisksSettings settings) throws IOException {
this.settings = settings;
this.stub = ((DisksStubSettings) settings.getStubSettings()).createStub();
}
protected DisksClient(DisksStub stub) {
this.settings = null;
this.stub = stub;
}
public final DisksSettings getSettings() {
return settings;
}
public DisksStub getStub() {
return stub;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Adds existing resource policies to a disk. You can only add one policy which will be applied to
* this disk for scheduling snapshot creation.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String disk = "disk3083677";
* DisksAddResourcePoliciesRequest disksAddResourcePoliciesRequestResource =
* DisksAddResourcePoliciesRequest.newBuilder().build();
* Operation response =
* disksClient
* .addResourcePoliciesAsync(
* project, zone, disk, disksAddResourcePoliciesRequestResource)
* .get();
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param disk The disk name for this request.
* @param disksAddResourcePoliciesRequestResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<Operation, Operation> addResourcePoliciesAsync(
String project,
String zone,
String disk,
DisksAddResourcePoliciesRequest disksAddResourcePoliciesRequestResource) {
AddResourcePoliciesDiskRequest request =
AddResourcePoliciesDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setDisk(disk)
.setDisksAddResourcePoliciesRequestResource(disksAddResourcePoliciesRequestResource)
.build();
return addResourcePoliciesAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Adds existing resource policies to a disk. You can only add one policy which will be applied to
* this disk for scheduling snapshot creation.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* AddResourcePoliciesDiskRequest request =
* AddResourcePoliciesDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksAddResourcePoliciesRequestResource(
* DisksAddResourcePoliciesRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* Operation response = disksClient.addResourcePoliciesAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> addResourcePoliciesAsync(
AddResourcePoliciesDiskRequest request) {
return addResourcePoliciesOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Adds existing resource policies to a disk. You can only add one policy which will be applied to
* this disk for scheduling snapshot creation.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* AddResourcePoliciesDiskRequest request =
* AddResourcePoliciesDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksAddResourcePoliciesRequestResource(
* DisksAddResourcePoliciesRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* OperationFuture<Operation, Operation> future =
* disksClient.addResourcePoliciesOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<AddResourcePoliciesDiskRequest, Operation, Operation>
addResourcePoliciesOperationCallable() {
return stub.addResourcePoliciesOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Adds existing resource policies to a disk. You can only add one policy which will be applied to
* this disk for scheduling snapshot creation.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* AddResourcePoliciesDiskRequest request =
* AddResourcePoliciesDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksAddResourcePoliciesRequestResource(
* DisksAddResourcePoliciesRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* ApiFuture<Operation> future = disksClient.addResourcePoliciesCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<AddResourcePoliciesDiskRequest, Operation>
addResourcePoliciesCallable() {
return stub.addResourcePoliciesCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves an aggregated list of persistent disks.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* for (Map.Entry<String, DisksScopedList> element :
* disksClient.aggregatedList(project).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param project Project ID for this request.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AggregatedListPagedResponse aggregatedList(String project) {
AggregatedListDisksRequest request =
AggregatedListDisksRequest.newBuilder().setProject(project).build();
return aggregatedList(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves an aggregated list of persistent disks.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* AggregatedListDisksRequest request =
* AggregatedListDisksRequest.newBuilder()
* .setFilter("filter-1274492040")
* .setIncludeAllScopes(true)
* .setMaxResults(1128457243)
* .setOrderBy("orderBy-1207110587")
* .setPageToken("pageToken873572522")
* .setProject("project-309310695")
* .setReturnPartialSuccess(true)
* .build();
* for (Map.Entry<String, DisksScopedList> element :
* disksClient.aggregatedList(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AggregatedListPagedResponse aggregatedList(AggregatedListDisksRequest request) {
return aggregatedListPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves an aggregated list of persistent disks.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* AggregatedListDisksRequest request =
* AggregatedListDisksRequest.newBuilder()
* .setFilter("filter-1274492040")
* .setIncludeAllScopes(true)
* .setMaxResults(1128457243)
* .setOrderBy("orderBy-1207110587")
* .setPageToken("pageToken873572522")
* .setProject("project-309310695")
* .setReturnPartialSuccess(true)
* .build();
* ApiFuture<Map.Entry<String, DisksScopedList>> future =
* disksClient.aggregatedListPagedCallable().futureCall(request);
* // Do something.
* for (Map.Entry<String, DisksScopedList> element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*/
public final UnaryCallable<AggregatedListDisksRequest, AggregatedListPagedResponse>
aggregatedListPagedCallable() {
return stub.aggregatedListPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves an aggregated list of persistent disks.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* AggregatedListDisksRequest request =
* AggregatedListDisksRequest.newBuilder()
* .setFilter("filter-1274492040")
* .setIncludeAllScopes(true)
* .setMaxResults(1128457243)
* .setOrderBy("orderBy-1207110587")
* .setPageToken("pageToken873572522")
* .setProject("project-309310695")
* .setReturnPartialSuccess(true)
* .build();
* while (true) {
* DiskAggregatedList response = disksClient.aggregatedListCallable().call(request);
* for (Map.Entry<String, DisksScopedList> element : response.getItemsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }</pre>
*/
public final UnaryCallable<AggregatedListDisksRequest, DiskAggregatedList>
aggregatedListCallable() {
return stub.aggregatedListCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider
* using snapshots.insert instead, as that method supports more features, such as creating
* snapshots in a project different from the source disk project.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String disk = "disk3083677";
* Snapshot snapshotResource = Snapshot.newBuilder().build();
* Operation response =
* disksClient.createSnapshotAsync(project, zone, disk, snapshotResource).get();
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param disk Name of the persistent disk to snapshot.
* @param snapshotResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<Operation, Operation> createSnapshotAsync(
String project, String zone, String disk, Snapshot snapshotResource) {
CreateSnapshotDiskRequest request =
CreateSnapshotDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setDisk(disk)
.setSnapshotResource(snapshotResource)
.build();
return createSnapshotAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider
* using snapshots.insert instead, as that method supports more features, such as creating
* snapshots in a project different from the source disk project.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* CreateSnapshotDiskRequest request =
* CreateSnapshotDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setGuestFlush(true)
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setSnapshotResource(Snapshot.newBuilder().build())
* .setZone("zone3744684")
* .build();
* Operation response = disksClient.createSnapshotAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> createSnapshotAsync(
CreateSnapshotDiskRequest request) {
return createSnapshotOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider
* using snapshots.insert instead, as that method supports more features, such as creating
* snapshots in a project different from the source disk project.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* CreateSnapshotDiskRequest request =
* CreateSnapshotDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setGuestFlush(true)
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setSnapshotResource(Snapshot.newBuilder().build())
* .setZone("zone3744684")
* .build();
* OperationFuture<Operation, Operation> future =
* disksClient.createSnapshotOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<CreateSnapshotDiskRequest, Operation, Operation>
createSnapshotOperationCallable() {
return stub.createSnapshotOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider
* using snapshots.insert instead, as that method supports more features, such as creating
* snapshots in a project different from the source disk project.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* CreateSnapshotDiskRequest request =
* CreateSnapshotDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setGuestFlush(true)
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setSnapshotResource(Snapshot.newBuilder().build())
* .setZone("zone3744684")
* .build();
* ApiFuture<Operation> future = disksClient.createSnapshotCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<CreateSnapshotDiskRequest, Operation> createSnapshotCallable() {
return stub.createSnapshotCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified persistent disk. Deleting a disk removes its data permanently and is
* irreversible. However, deleting a disk does not delete any snapshots previously made from the
* disk. You must separately delete snapshots.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String disk = "disk3083677";
* Operation response = disksClient.deleteAsync(project, zone, disk).get();
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param disk Name of the persistent disk to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<Operation, Operation> deleteAsync(
String project, String zone, String disk) {
DeleteDiskRequest request =
DeleteDiskRequest.newBuilder().setProject(project).setZone(zone).setDisk(disk).build();
return deleteAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified persistent disk. Deleting a disk removes its data permanently and is
* irreversible. However, deleting a disk does not delete any snapshots previously made from the
* disk. You must separately delete snapshots.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* DeleteDiskRequest request =
* DeleteDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* Operation response = disksClient.deleteAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> deleteAsync(DeleteDiskRequest request) {
return deleteOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified persistent disk. Deleting a disk removes its data permanently and is
* irreversible. However, deleting a disk does not delete any snapshots previously made from the
* disk. You must separately delete snapshots.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* DeleteDiskRequest request =
* DeleteDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* OperationFuture<Operation, Operation> future =
* disksClient.deleteOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<DeleteDiskRequest, Operation, Operation>
deleteOperationCallable() {
return stub.deleteOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified persistent disk. Deleting a disk removes its data permanently and is
* irreversible. However, deleting a disk does not delete any snapshots previously made from the
* disk. You must separately delete snapshots.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* DeleteDiskRequest request =
* DeleteDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* ApiFuture<Operation> future = disksClient.deleteCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<DeleteDiskRequest, Operation> deleteCallable() {
return stub.deleteCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a specified persistent disk. Gets a list of available persistent disks by making a
* list() request.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String disk = "disk3083677";
* Disk response = disksClient.get(project, zone, disk);
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param disk Name of the persistent disk to return.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Disk get(String project, String zone, String disk) {
GetDiskRequest request =
GetDiskRequest.newBuilder().setProject(project).setZone(zone).setDisk(disk).build();
return get(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a specified persistent disk. Gets a list of available persistent disks by making a
* list() request.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* GetDiskRequest request =
* GetDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setProject("project-309310695")
* .setZone("zone3744684")
* .build();
* Disk response = disksClient.get(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Disk get(GetDiskRequest request) {
return getCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a specified persistent disk. Gets a list of available persistent disks by making a
* list() request.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* GetDiskRequest request =
* GetDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setProject("project-309310695")
* .setZone("zone3744684")
* .build();
* ApiFuture<Disk> future = disksClient.getCallable().futureCall(request);
* // Do something.
* Disk response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<GetDiskRequest, Disk> getCallable() {
return stub.getCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the access control policy for a resource. May be empty if no such policy or resource
* exists.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String resource = "resource-341064690";
* Policy response = disksClient.getIamPolicy(project, zone, resource);
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param resource Name or id of the resource for this request.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy getIamPolicy(String project, String zone, String resource) {
GetIamPolicyDiskRequest request =
GetIamPolicyDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setResource(resource)
.build();
return getIamPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the access control policy for a resource. May be empty if no such policy or resource
* exists.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* GetIamPolicyDiskRequest request =
* GetIamPolicyDiskRequest.newBuilder()
* .setOptionsRequestedPolicyVersion(-574521795)
* .setProject("project-309310695")
* .setResource("resource-341064690")
* .setZone("zone3744684")
* .build();
* Policy response = disksClient.getIamPolicy(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy getIamPolicy(GetIamPolicyDiskRequest request) {
return getIamPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the access control policy for a resource. May be empty if no such policy or resource
* exists.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* GetIamPolicyDiskRequest request =
* GetIamPolicyDiskRequest.newBuilder()
* .setOptionsRequestedPolicyVersion(-574521795)
* .setProject("project-309310695")
* .setResource("resource-341064690")
* .setZone("zone3744684")
* .build();
* ApiFuture<Policy> future = disksClient.getIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<GetIamPolicyDiskRequest, Policy> getIamPolicyCallable() {
return stub.getIamPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a persistent disk in the specified project using the data in the request. You can
* create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500
* GB data disk by omitting all properties. You can also create a disk that is larger than the
* default size by specifying the sizeGb property.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* Disk diskResource = Disk.newBuilder().build();
* Operation response = disksClient.insertAsync(project, zone, diskResource).get();
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param diskResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<Operation, Operation> insertAsync(
String project, String zone, Disk diskResource) {
InsertDiskRequest request =
InsertDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setDiskResource(diskResource)
.build();
return insertAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a persistent disk in the specified project using the data in the request. You can
* create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500
* GB data disk by omitting all properties. You can also create a disk that is larger than the
* default size by specifying the sizeGb property.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* InsertDiskRequest request =
* InsertDiskRequest.newBuilder()
* .setDiskResource(Disk.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setSourceImage("sourceImage-105174528")
* .setZone("zone3744684")
* .build();
* Operation response = disksClient.insertAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> insertAsync(InsertDiskRequest request) {
return insertOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a persistent disk in the specified project using the data in the request. You can
* create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500
* GB data disk by omitting all properties. You can also create a disk that is larger than the
* default size by specifying the sizeGb property.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* InsertDiskRequest request =
* InsertDiskRequest.newBuilder()
* .setDiskResource(Disk.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setSourceImage("sourceImage-105174528")
* .setZone("zone3744684")
* .build();
* OperationFuture<Operation, Operation> future =
* disksClient.insertOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<InsertDiskRequest, Operation, Operation>
insertOperationCallable() {
return stub.insertOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a persistent disk in the specified project using the data in the request. You can
* create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500
* GB data disk by omitting all properties. You can also create a disk that is larger than the
* default size by specifying the sizeGb property.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* InsertDiskRequest request =
* InsertDiskRequest.newBuilder()
* .setDiskResource(Disk.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setSourceImage("sourceImage-105174528")
* .setZone("zone3744684")
* .build();
* ApiFuture<Operation> future = disksClient.insertCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<InsertDiskRequest, Operation> insertCallable() {
return stub.insertCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves a list of persistent disks contained within the specified zone.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* for (Disk element : disksClient.list(project, zone).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListPagedResponse list(String project, String zone) {
ListDisksRequest request =
ListDisksRequest.newBuilder().setProject(project).setZone(zone).build();
return list(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves a list of persistent disks contained within the specified zone.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* ListDisksRequest request =
* ListDisksRequest.newBuilder()
* .setFilter("filter-1274492040")
* .setMaxResults(1128457243)
* .setOrderBy("orderBy-1207110587")
* .setPageToken("pageToken873572522")
* .setProject("project-309310695")
* .setReturnPartialSuccess(true)
* .setZone("zone3744684")
* .build();
* for (Disk element : disksClient.list(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListPagedResponse list(ListDisksRequest request) {
return listPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves a list of persistent disks contained within the specified zone.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* ListDisksRequest request =
* ListDisksRequest.newBuilder()
* .setFilter("filter-1274492040")
* .setMaxResults(1128457243)
* .setOrderBy("orderBy-1207110587")
* .setPageToken("pageToken873572522")
* .setProject("project-309310695")
* .setReturnPartialSuccess(true)
* .setZone("zone3744684")
* .build();
* ApiFuture<Disk> future = disksClient.listPagedCallable().futureCall(request);
* // Do something.
* for (Disk element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*/
public final UnaryCallable<ListDisksRequest, ListPagedResponse> listPagedCallable() {
return stub.listPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves a list of persistent disks contained within the specified zone.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* ListDisksRequest request =
* ListDisksRequest.newBuilder()
* .setFilter("filter-1274492040")
* .setMaxResults(1128457243)
* .setOrderBy("orderBy-1207110587")
* .setPageToken("pageToken873572522")
* .setProject("project-309310695")
* .setReturnPartialSuccess(true)
* .setZone("zone3744684")
* .build();
* while (true) {
* DiskList response = disksClient.listCallable().call(request);
* for (Disk element : response.getItemsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }</pre>
*/
public final UnaryCallable<ListDisksRequest, DiskList> listCallable() {
return stub.listCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Removes resource policies from a disk.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String disk = "disk3083677";
* DisksRemoveResourcePoliciesRequest disksRemoveResourcePoliciesRequestResource =
* DisksRemoveResourcePoliciesRequest.newBuilder().build();
* Operation response =
* disksClient
* .removeResourcePoliciesAsync(
* project, zone, disk, disksRemoveResourcePoliciesRequestResource)
* .get();
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param disk The disk name for this request.
* @param disksRemoveResourcePoliciesRequestResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<Operation, Operation> removeResourcePoliciesAsync(
String project,
String zone,
String disk,
DisksRemoveResourcePoliciesRequest disksRemoveResourcePoliciesRequestResource) {
RemoveResourcePoliciesDiskRequest request =
RemoveResourcePoliciesDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setDisk(disk)
.setDisksRemoveResourcePoliciesRequestResource(
disksRemoveResourcePoliciesRequestResource)
.build();
return removeResourcePoliciesAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Removes resource policies from a disk.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* RemoveResourcePoliciesDiskRequest request =
* RemoveResourcePoliciesDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksRemoveResourcePoliciesRequestResource(
* DisksRemoveResourcePoliciesRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* Operation response = disksClient.removeResourcePoliciesAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> removeResourcePoliciesAsync(
RemoveResourcePoliciesDiskRequest request) {
return removeResourcePoliciesOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Removes resource policies from a disk.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* RemoveResourcePoliciesDiskRequest request =
* RemoveResourcePoliciesDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksRemoveResourcePoliciesRequestResource(
* DisksRemoveResourcePoliciesRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* OperationFuture<Operation, Operation> future =
* disksClient.removeResourcePoliciesOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<RemoveResourcePoliciesDiskRequest, Operation, Operation>
removeResourcePoliciesOperationCallable() {
return stub.removeResourcePoliciesOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Removes resource policies from a disk.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* RemoveResourcePoliciesDiskRequest request =
* RemoveResourcePoliciesDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksRemoveResourcePoliciesRequestResource(
* DisksRemoveResourcePoliciesRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* ApiFuture<Operation> future =
* disksClient.removeResourcePoliciesCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<RemoveResourcePoliciesDiskRequest, Operation>
removeResourcePoliciesCallable() {
return stub.removeResourcePoliciesCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Resizes the specified persistent disk. You can only increase the size of the disk.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String disk = "disk3083677";
* DisksResizeRequest disksResizeRequestResource = DisksResizeRequest.newBuilder().build();
* Operation response =
* disksClient.resizeAsync(project, zone, disk, disksResizeRequestResource).get();
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param disk The name of the persistent disk.
* @param disksResizeRequestResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<Operation, Operation> resizeAsync(
String project, String zone, String disk, DisksResizeRequest disksResizeRequestResource) {
ResizeDiskRequest request =
ResizeDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setDisk(disk)
.setDisksResizeRequestResource(disksResizeRequestResource)
.build();
return resizeAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Resizes the specified persistent disk. You can only increase the size of the disk.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* ResizeDiskRequest request =
* ResizeDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksResizeRequestResource(DisksResizeRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* Operation response = disksClient.resizeAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> resizeAsync(ResizeDiskRequest request) {
return resizeOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Resizes the specified persistent disk. You can only increase the size of the disk.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* ResizeDiskRequest request =
* ResizeDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksResizeRequestResource(DisksResizeRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* OperationFuture<Operation, Operation> future =
* disksClient.resizeOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<ResizeDiskRequest, Operation, Operation>
resizeOperationCallable() {
return stub.resizeOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Resizes the specified persistent disk. You can only increase the size of the disk.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* ResizeDiskRequest request =
* ResizeDiskRequest.newBuilder()
* .setDisk("disk3083677")
* .setDisksResizeRequestResource(DisksResizeRequest.newBuilder().build())
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setZone("zone3744684")
* .build();
* ApiFuture<Operation> future = disksClient.resizeCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<ResizeDiskRequest, Operation> resizeCallable() {
return stub.resizeCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the access control policy on the specified resource. Replaces any existing policy.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String resource = "resource-341064690";
* ZoneSetPolicyRequest zoneSetPolicyRequestResource = ZoneSetPolicyRequest.newBuilder().build();
* Policy response =
* disksClient.setIamPolicy(project, zone, resource, zoneSetPolicyRequestResource);
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param resource Name or id of the resource for this request.
* @param zoneSetPolicyRequestResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy setIamPolicy(
String project,
String zone,
String resource,
ZoneSetPolicyRequest zoneSetPolicyRequestResource) {
SetIamPolicyDiskRequest request =
SetIamPolicyDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setResource(resource)
.setZoneSetPolicyRequestResource(zoneSetPolicyRequestResource)
.build();
return setIamPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the access control policy on the specified resource. Replaces any existing policy.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* SetIamPolicyDiskRequest request =
* SetIamPolicyDiskRequest.newBuilder()
* .setProject("project-309310695")
* .setResource("resource-341064690")
* .setZone("zone3744684")
* .setZoneSetPolicyRequestResource(ZoneSetPolicyRequest.newBuilder().build())
* .build();
* Policy response = disksClient.setIamPolicy(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy setIamPolicy(SetIamPolicyDiskRequest request) {
return setIamPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the access control policy on the specified resource. Replaces any existing policy.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* SetIamPolicyDiskRequest request =
* SetIamPolicyDiskRequest.newBuilder()
* .setProject("project-309310695")
* .setResource("resource-341064690")
* .setZone("zone3744684")
* .setZoneSetPolicyRequestResource(ZoneSetPolicyRequest.newBuilder().build())
* .build();
* ApiFuture<Policy> future = disksClient.setIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SetIamPolicyDiskRequest, Policy> setIamPolicyCallable() {
return stub.setIamPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the labels on a disk. To learn more about labels, read the Labeling Resources
* documentation.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String resource = "resource-341064690";
* ZoneSetLabelsRequest zoneSetLabelsRequestResource = ZoneSetLabelsRequest.newBuilder().build();
* Operation response =
* disksClient.setLabelsAsync(project, zone, resource, zoneSetLabelsRequestResource).get();
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param resource Name or id of the resource for this request.
* @param zoneSetLabelsRequestResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<Operation, Operation> setLabelsAsync(
String project,
String zone,
String resource,
ZoneSetLabelsRequest zoneSetLabelsRequestResource) {
SetLabelsDiskRequest request =
SetLabelsDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setResource(resource)
.setZoneSetLabelsRequestResource(zoneSetLabelsRequestResource)
.build();
return setLabelsAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the labels on a disk. To learn more about labels, read the Labeling Resources
* documentation.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* SetLabelsDiskRequest request =
* SetLabelsDiskRequest.newBuilder()
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setResource("resource-341064690")
* .setZone("zone3744684")
* .setZoneSetLabelsRequestResource(ZoneSetLabelsRequest.newBuilder().build())
* .build();
* Operation response = disksClient.setLabelsAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> setLabelsAsync(SetLabelsDiskRequest request) {
return setLabelsOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the labels on a disk. To learn more about labels, read the Labeling Resources
* documentation.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* SetLabelsDiskRequest request =
* SetLabelsDiskRequest.newBuilder()
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setResource("resource-341064690")
* .setZone("zone3744684")
* .setZoneSetLabelsRequestResource(ZoneSetLabelsRequest.newBuilder().build())
* .build();
* OperationFuture<Operation, Operation> future =
* disksClient.setLabelsOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<SetLabelsDiskRequest, Operation, Operation>
setLabelsOperationCallable() {
return stub.setLabelsOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the labels on a disk. To learn more about labels, read the Labeling Resources
* documentation.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* SetLabelsDiskRequest request =
* SetLabelsDiskRequest.newBuilder()
* .setProject("project-309310695")
* .setRequestId("requestId693933066")
* .setResource("resource-341064690")
* .setZone("zone3744684")
* .setZoneSetLabelsRequestResource(ZoneSetLabelsRequest.newBuilder().build())
* .build();
* ApiFuture<Operation> future = disksClient.setLabelsCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SetLabelsDiskRequest, Operation> setLabelsCallable() {
return stub.setLabelsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns permissions that a caller has on the specified resource.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* String project = "project-309310695";
* String zone = "zone3744684";
* String resource = "resource-341064690";
* TestPermissionsRequest testPermissionsRequestResource =
* TestPermissionsRequest.newBuilder().build();
* TestPermissionsResponse response =
* disksClient.testIamPermissions(project, zone, resource, testPermissionsRequestResource);
* }
* }</pre>
*
* @param project Project ID for this request.
* @param zone The name of the zone for this request.
* @param resource Name or id of the resource for this request.
* @param testPermissionsRequestResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TestPermissionsResponse testIamPermissions(
String project,
String zone,
String resource,
TestPermissionsRequest testPermissionsRequestResource) {
TestIamPermissionsDiskRequest request =
TestIamPermissionsDiskRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setResource(resource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
return testIamPermissions(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns permissions that a caller has on the specified resource.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* TestIamPermissionsDiskRequest request =
* TestIamPermissionsDiskRequest.newBuilder()
* .setProject("project-309310695")
* .setResource("resource-341064690")
* .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
* .setZone("zone3744684")
* .build();
* TestPermissionsResponse response = disksClient.testIamPermissions(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TestPermissionsResponse testIamPermissions(TestIamPermissionsDiskRequest request) {
return testIamPermissionsCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns permissions that a caller has on the specified resource.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (DisksClient disksClient = DisksClient.create()) {
* TestIamPermissionsDiskRequest request =
* TestIamPermissionsDiskRequest.newBuilder()
* .setProject("project-309310695")
* .setResource("resource-341064690")
* .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
* .setZone("zone3744684")
* .build();
* ApiFuture<TestPermissionsResponse> future =
* disksClient.testIamPermissionsCallable().futureCall(request);
* // Do something.
* TestPermissionsResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<TestIamPermissionsDiskRequest, TestPermissionsResponse>
testIamPermissionsCallable() {
return stub.testIamPermissionsCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class AggregatedListPagedResponse
extends AbstractPagedListResponse<
AggregatedListDisksRequest,
DiskAggregatedList,
Map.Entry<String, DisksScopedList>,
AggregatedListPage,
AggregatedListFixedSizeCollection> {
public static ApiFuture<AggregatedListPagedResponse> createAsync(
PageContext<
AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>>
context,
ApiFuture<DiskAggregatedList> futureResponse) {
ApiFuture<AggregatedListPage> futurePage =
AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new AggregatedListPagedResponse(input),
MoreExecutors.directExecutor());
}
private AggregatedListPagedResponse(AggregatedListPage page) {
super(page, AggregatedListFixedSizeCollection.createEmptyCollection());
}
}
public static class AggregatedListPage
extends AbstractPage<
AggregatedListDisksRequest,
DiskAggregatedList,
Map.Entry<String, DisksScopedList>,
AggregatedListPage> {
private AggregatedListPage(
PageContext<
AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>>
context,
DiskAggregatedList response) {
super(context, response);
}
private static AggregatedListPage createEmptyPage() {
return new AggregatedListPage(null, null);
}
@Override
protected AggregatedListPage createPage(
PageContext<
AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>>
context,
DiskAggregatedList response) {
return new AggregatedListPage(context, response);
}
@Override
public ApiFuture<AggregatedListPage> createPageAsync(
PageContext<
AggregatedListDisksRequest, DiskAggregatedList, Map.Entry<String, DisksScopedList>>
context,
ApiFuture<DiskAggregatedList> futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class AggregatedListFixedSizeCollection
extends AbstractFixedSizeCollection<
AggregatedListDisksRequest,
DiskAggregatedList,
Map.Entry<String, DisksScopedList>,
AggregatedListPage,
AggregatedListFixedSizeCollection> {
private AggregatedListFixedSizeCollection(List<AggregatedListPage> pages, int collectionSize) {
super(pages, collectionSize);
}
private static AggregatedListFixedSizeCollection createEmptyCollection() {
return new AggregatedListFixedSizeCollection(null, 0);
}
@Override
protected AggregatedListFixedSizeCollection createCollection(
List<AggregatedListPage> pages, int collectionSize) {
return new AggregatedListFixedSizeCollection(pages, collectionSize);
}
}
public static class ListPagedResponse
extends AbstractPagedListResponse<
ListDisksRequest, DiskList, Disk, ListPage, ListFixedSizeCollection> {
public static ApiFuture<ListPagedResponse> createAsync(
PageContext<ListDisksRequest, DiskList, Disk> context, ApiFuture<DiskList> futureResponse) {
ApiFuture<ListPage> futurePage =
ListPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
}
private ListPagedResponse(ListPage page) {
super(page, ListFixedSizeCollection.createEmptyCollection());
}
}
public static class ListPage extends AbstractPage<ListDisksRequest, DiskList, Disk, ListPage> {
private ListPage(PageContext<ListDisksRequest, DiskList, Disk> context, DiskList response) {
super(context, response);
}
private static ListPage createEmptyPage() {
return new ListPage(null, null);
}
@Override
protected ListPage createPage(
PageContext<ListDisksRequest, DiskList, Disk> context, DiskList response) {
return new ListPage(context, response);
}
@Override
public ApiFuture<ListPage> createPageAsync(
PageContext<ListDisksRequest, DiskList, Disk> context, ApiFuture<DiskList> futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListFixedSizeCollection
extends AbstractFixedSizeCollection<
ListDisksRequest, DiskList, Disk, ListPage, ListFixedSizeCollection> {
private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListFixedSizeCollection createEmptyCollection() {
return new ListFixedSizeCollection(null, 0);
}
@Override
protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
return new ListFixedSizeCollection(pages, collectionSize);
}
}
}