- 1.64.0 (latest)
- 1.63.0
- 1.62.0
- 1.61.0
- 1.59.0
- 1.58.0
- 1.57.0
- 1.56.0
- 1.55.0
- 1.54.0
- 1.53.0
- 1.52.0
- 1.51.0
- 1.50.0
- 1.49.0
- 1.47.0
- 1.46.0
- 1.45.0
- 1.44.0
- 1.43.0
- 1.42.0
- 1.41.0
- 1.40.0
- 1.39.0
- 1.38.0
- 1.37.0
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.0
- 1.29.0
- 1.28.0
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.0
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.1
- 1.11.0
- 1.9.1
- 1.8.1
- 1.7.2
- 1.6.0-beta
public class DisksClient implements BackgroundResource
Service Description: The Disks API.
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:
try (DisksClient disksClient = DisksClient.create()) {
String project = "project-309310695";
String zone = "zone3744684";
String disk = "disk3083677";
Disk response = disksClient.get(project, zone, disk);
}
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().
The surface of this class includes several types of Java methods for each of the API's methods:
- 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.
- 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.
- 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.
See the individual methods for example code.
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.
This class can be customized by passing in a custom instance of DisksSettings to create(). For example:
To customize credentials:
DisksSettings disksSettings =
DisksSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DisksClient disksClient = DisksClient.create(disksSettings);
To customize the endpoint:
DisksSettings disksSettings = DisksSettings.newBuilder().setEndpoint(myEndpoint).build();
DisksClient disksClient = DisksClient.create(disksSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final DisksClient create()
Constructs an instance of DisksClient with default settings.
Type | Description |
DisksClient |
Type | Description |
IOException |
create(DisksSettings settings)
public static final DisksClient create(DisksSettings settings)
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.
Name | Description |
settings | DisksSettings |
Type | Description |
DisksClient |
Type | Description |
IOException |
create(DisksStub stub)
public static final DisksClient create(DisksStub stub)
Constructs an instance of DisksClient, using the given stub for making calls. This is for advanced usage - prefer using create(DisksSettings).
Name | Description |
stub | DisksStub |
Type | Description |
DisksClient |
Constructors
DisksClient(DisksSettings settings)
protected DisksClient(DisksSettings settings)
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.
Name | Description |
settings | DisksSettings |
DisksClient(DisksStub stub)
protected DisksClient(DisksStub stub)
Name | Description |
stub | DisksStub |
Methods
addResourcePoliciesAsync(AddResourcePoliciesDiskRequest request)
public final OperationFuture<Operation,Operation> addResourcePoliciesAsync(AddResourcePoliciesDiskRequest request)
Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.
Sample code:
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();
}
Name | Description |
request | AddResourcePoliciesDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Operation,Operation> |
addResourcePoliciesAsync(String project, String zone, String disk, DisksAddResourcePoliciesRequest disksAddResourcePoliciesRequestResource)
public final OperationFuture<Operation,Operation> addResourcePoliciesAsync(String project, String zone, String disk, DisksAddResourcePoliciesRequest disksAddResourcePoliciesRequestResource)
Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.
Sample code:
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();
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
disk | String The disk name for this request. |
disksAddResourcePoliciesRequestResource | DisksAddResourcePoliciesRequest The body resource for this request |
Type | Description |
OperationFuture<Operation,Operation> |
addResourcePoliciesCallable()
public final UnaryCallable<AddResourcePoliciesDiskRequest,Operation> addResourcePoliciesCallable()
Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.
Sample code:
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();
}
Type | Description |
UnaryCallable<AddResourcePoliciesDiskRequest,Operation> |
addResourcePoliciesOperationCallable()
public final OperationCallable<AddResourcePoliciesDiskRequest,Operation,Operation> addResourcePoliciesOperationCallable()
Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
AddResourcePoliciesDiskRequest request =
AddResourcePoliciesDiskRequest.newBuilder()
.setDisk("disk3083677")
.setDisksAddResourcePoliciesRequestResource(
DisksAddResourcePoliciesRequest.newBuilder().build())
.setProject("project-309310695")
.setRequestId("requestId693933066")
.setZone("zone3744684")
.build();
OperationFuture
Type | Description |
OperationCallable<AddResourcePoliciesDiskRequest,Operation,Operation> |
aggregatedList(AggregatedListDisksRequest request)
public final DisksClient.AggregatedListPagedResponse aggregatedList(AggregatedListDisksRequest request)
Retrieves an aggregated list of persistent disks.
Sample code:
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
Name | Description |
request | AggregatedListDisksRequest The request object containing all of the parameters for the API call. |
Type | Description |
DisksClient.AggregatedListPagedResponse |
aggregatedList(String project)
public final DisksClient.AggregatedListPagedResponse aggregatedList(String project)
Retrieves an aggregated list of persistent disks.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
String project = "project-309310695";
for (Map.Entry
Name | Description |
project | String Project ID for this request. |
Type | Description |
DisksClient.AggregatedListPagedResponse |
aggregatedListCallable()
public final UnaryCallable<AggregatedListDisksRequest,DiskAggregatedList> aggregatedListCallable()
Retrieves an aggregated list of persistent disks.
Sample code:
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
Type | Description |
UnaryCallable<AggregatedListDisksRequest,DiskAggregatedList> |
aggregatedListPagedCallable()
public final UnaryCallable<AggregatedListDisksRequest,DisksClient.AggregatedListPagedResponse> aggregatedListPagedCallable()
Retrieves an aggregated list of persistent disks.
Sample code:
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<>
Type | Description |
UnaryCallable<AggregatedListDisksRequest,AggregatedListPagedResponse> |
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createSnapshotAsync(CreateSnapshotDiskRequest request)
public final OperationFuture<Operation,Operation> createSnapshotAsync(CreateSnapshotDiskRequest request)
Creates a snapshot of a specified persistent disk.
Sample code:
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();
}
Name | Description |
request | CreateSnapshotDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Operation,Operation> |
createSnapshotAsync(String project, String zone, String disk, Snapshot snapshotResource)
public final OperationFuture<Operation,Operation> createSnapshotAsync(String project, String zone, String disk, Snapshot snapshotResource)
Creates a snapshot of a specified persistent disk.
Sample code:
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();
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
disk | String Name of the persistent disk to snapshot. |
snapshotResource | Snapshot The body resource for this request |
Type | Description |
OperationFuture<Operation,Operation> |
createSnapshotCallable()
public final UnaryCallable<CreateSnapshotDiskRequest,Operation> createSnapshotCallable()
Creates a snapshot of a specified persistent disk.
Sample code:
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();
}
Type | Description |
UnaryCallable<CreateSnapshotDiskRequest,Operation> |
createSnapshotOperationCallable()
public final OperationCallable<CreateSnapshotDiskRequest,Operation,Operation> createSnapshotOperationCallable()
Creates a snapshot of a specified persistent disk.
Sample code:
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
Type | Description |
OperationCallable<CreateSnapshotDiskRequest,Operation,Operation> |
deleteAsync(DeleteDiskRequest request)
public final OperationFuture<Operation,Operation> deleteAsync(DeleteDiskRequest request)
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.
Sample code:
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();
}
Name | Description |
request | DeleteDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Operation,Operation> |
deleteAsync(String project, String zone, String disk)
public final OperationFuture<Operation,Operation> deleteAsync(String project, String zone, String disk)
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.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
String project = "project-309310695";
String zone = "zone3744684";
String disk = "disk3083677";
Operation response = disksClient.deleteAsync(project, zone, disk).get();
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
disk | String Name of the persistent disk to delete. |
Type | Description |
OperationFuture<Operation,Operation> |
deleteCallable()
public final UnaryCallable<DeleteDiskRequest,Operation> deleteCallable()
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.
Sample code:
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();
}
Type | Description |
UnaryCallable<DeleteDiskRequest,Operation> |
deleteOperationCallable()
public final OperationCallable<DeleteDiskRequest,Operation,Operation> deleteOperationCallable()
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.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
DeleteDiskRequest request =
DeleteDiskRequest.newBuilder()
.setDisk("disk3083677")
.setProject("project-309310695")
.setRequestId("requestId693933066")
.setZone("zone3744684")
.build();
OperationFuture
Type | Description |
OperationCallable<DeleteDiskRequest,Operation,Operation> |
get(GetDiskRequest request)
public final Disk get(GetDiskRequest request)
Returns a specified persistent disk. Gets a list of available persistent disks by making a list() request.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
GetDiskRequest request =
GetDiskRequest.newBuilder()
.setDisk("disk3083677")
.setProject("project-309310695")
.setZone("zone3744684")
.build();
Disk response = disksClient.get(request);
}
Name | Description |
request | GetDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
Disk |
get(String project, String zone, String disk)
public final Disk get(String project, String zone, String disk)
Returns a specified persistent disk. Gets a list of available persistent disks by making a list() request.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
String project = "project-309310695";
String zone = "zone3744684";
String disk = "disk3083677";
Disk response = disksClient.get(project, zone, disk);
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
disk | String Name of the persistent disk to return. |
Type | Description |
Disk |
getCallable()
public final UnaryCallable<GetDiskRequest,Disk> getCallable()
Returns a specified persistent disk. Gets a list of available persistent disks by making a list() request.
Sample code:
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();
}
Type | Description |
UnaryCallable<GetDiskRequest,Disk> |
getIamPolicy(GetIamPolicyDiskRequest request)
public final Policy getIamPolicy(GetIamPolicyDiskRequest request)
Gets the access control policy for a resource. May be empty if no such policy or resource exists.
Sample code:
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);
}
Name | Description |
request | GetIamPolicyDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
Policy |
getIamPolicy(String project, String zone, String resource)
public final Policy getIamPolicy(String project, String zone, String resource)
Gets the access control policy for a resource. May be empty if no such policy or resource exists.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
String project = "project-309310695";
String zone = "zone3744684";
String resource = "resource-341064690";
Policy response = disksClient.getIamPolicy(project, zone, resource);
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
resource | String Name or id of the resource for this request. |
Type | Description |
Policy |
getIamPolicyCallable()
public final UnaryCallable<GetIamPolicyDiskRequest,Policy> getIamPolicyCallable()
Gets the access control policy for a resource. May be empty if no such policy or resource exists.
Sample code:
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();
}
Type | Description |
UnaryCallable<GetIamPolicyDiskRequest,Policy> |
getSettings()
public final DisksSettings getSettings()
Type | Description |
DisksSettings |
getStub()
public DisksStub getStub()
Type | Description |
DisksStub |
insertAsync(InsertDiskRequest request)
public final OperationFuture<Operation,Operation> insertAsync(InsertDiskRequest request)
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.
Sample code:
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();
}
Name | Description |
request | InsertDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Operation,Operation> |
insertAsync(String project, String zone, Disk diskResource)
public final OperationFuture<Operation,Operation> insertAsync(String project, String zone, Disk diskResource)
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.
Sample code:
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();
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
diskResource | Disk The body resource for this request |
Type | Description |
OperationFuture<Operation,Operation> |
insertCallable()
public final UnaryCallable<InsertDiskRequest,Operation> insertCallable()
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.
Sample code:
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();
}
Type | Description |
UnaryCallable<InsertDiskRequest,Operation> |
insertOperationCallable()
public final OperationCallable<InsertDiskRequest,Operation,Operation> insertOperationCallable()
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.
Sample code:
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
Type | Description |
OperationCallable<InsertDiskRequest,Operation,Operation> |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
list(ListDisksRequest request)
public final DisksClient.ListPagedResponse list(ListDisksRequest request)
Retrieves a list of persistent disks contained within the specified zone.
Sample code:
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);
}
}
Name | Description |
request | ListDisksRequest The request object containing all of the parameters for the API call. |
Type | Description |
DisksClient.ListPagedResponse |
list(String project, String zone)
public final DisksClient.ListPagedResponse list(String project, String zone)
Retrieves a list of persistent disks contained within the specified zone.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
String project = "project-309310695";
String zone = "zone3744684";
for (Disk element : disksClient.list(project, zone).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
Type | Description |
DisksClient.ListPagedResponse |
listCallable()
public final UnaryCallable<ListDisksRequest,DiskList> listCallable()
Retrieves a list of persistent disks contained within the specified zone.
Sample code:
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.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListDisksRequest,DiskList> |
listPagedCallable()
public final UnaryCallable<ListDisksRequest,DisksClient.ListPagedResponse> listPagedCallable()
Retrieves a list of persistent disks contained within the specified zone.
Sample code:
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);
}
}
Type | Description |
UnaryCallable<ListDisksRequest,ListPagedResponse> |
removeResourcePoliciesAsync(RemoveResourcePoliciesDiskRequest request)
public final OperationFuture<Operation,Operation> removeResourcePoliciesAsync(RemoveResourcePoliciesDiskRequest request)
Removes resource policies from a disk.
Sample code:
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();
}
Name | Description |
request | RemoveResourcePoliciesDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Operation,Operation> |
removeResourcePoliciesAsync(String project, String zone, String disk, DisksRemoveResourcePoliciesRequest disksRemoveResourcePoliciesRequestResource)
public final OperationFuture<Operation,Operation> removeResourcePoliciesAsync(String project, String zone, String disk, DisksRemoveResourcePoliciesRequest disksRemoveResourcePoliciesRequestResource)
Removes resource policies from a disk.
Sample code:
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();
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
disk | String The disk name for this request. |
disksRemoveResourcePoliciesRequestResource | DisksRemoveResourcePoliciesRequest The body resource for this request |
Type | Description |
OperationFuture<Operation,Operation> |
removeResourcePoliciesCallable()
public final UnaryCallable<RemoveResourcePoliciesDiskRequest,Operation> removeResourcePoliciesCallable()
Removes resource policies from a disk.
Sample code:
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();
}
Type | Description |
UnaryCallable<RemoveResourcePoliciesDiskRequest,Operation> |
removeResourcePoliciesOperationCallable()
public final OperationCallable<RemoveResourcePoliciesDiskRequest,Operation,Operation> removeResourcePoliciesOperationCallable()
Removes resource policies from a disk.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
RemoveResourcePoliciesDiskRequest request =
RemoveResourcePoliciesDiskRequest.newBuilder()
.setDisk("disk3083677")
.setDisksRemoveResourcePoliciesRequestResource(
DisksRemoveResourcePoliciesRequest.newBuilder().build())
.setProject("project-309310695")
.setRequestId("requestId693933066")
.setZone("zone3744684")
.build();
OperationFuture
Type | Description |
OperationCallable<RemoveResourcePoliciesDiskRequest,Operation,Operation> |
resizeAsync(ResizeDiskRequest request)
public final OperationFuture<Operation,Operation> resizeAsync(ResizeDiskRequest request)
Resizes the specified persistent disk. You can only increase the size of the disk.
Sample code:
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();
}
Name | Description |
request | ResizeDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Operation,Operation> |
resizeAsync(String project, String zone, String disk, DisksResizeRequest disksResizeRequestResource)
public final OperationFuture<Operation,Operation> resizeAsync(String project, String zone, String disk, DisksResizeRequest disksResizeRequestResource)
Resizes the specified persistent disk. You can only increase the size of the disk.
Sample code:
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();
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
disk | String The name of the persistent disk. |
disksResizeRequestResource | DisksResizeRequest The body resource for this request |
Type | Description |
OperationFuture<Operation,Operation> |
resizeCallable()
public final UnaryCallable<ResizeDiskRequest,Operation> resizeCallable()
Resizes the specified persistent disk. You can only increase the size of the disk.
Sample code:
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();
}
Type | Description |
UnaryCallable<ResizeDiskRequest,Operation> |
resizeOperationCallable()
public final OperationCallable<ResizeDiskRequest,Operation,Operation> resizeOperationCallable()
Resizes the specified persistent disk. You can only increase the size of the disk.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
ResizeDiskRequest request =
ResizeDiskRequest.newBuilder()
.setDisk("disk3083677")
.setDisksResizeRequestResource(DisksResizeRequest.newBuilder().build())
.setProject("project-309310695")
.setRequestId("requestId693933066")
.setZone("zone3744684")
.build();
OperationFuture
Type | Description |
OperationCallable<ResizeDiskRequest,Operation,Operation> |
setIamPolicy(SetIamPolicyDiskRequest request)
public final Policy setIamPolicy(SetIamPolicyDiskRequest request)
Sets the access control policy on the specified resource. Replaces any existing policy.
Sample code:
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);
}
Name | Description |
request | SetIamPolicyDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
Policy |
setIamPolicy(String project, String zone, String resource, ZoneSetPolicyRequest zoneSetPolicyRequestResource)
public final Policy setIamPolicy(String project, String zone, String resource, ZoneSetPolicyRequest zoneSetPolicyRequestResource)
Sets the access control policy on the specified resource. Replaces any existing policy.
Sample code:
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);
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
resource | String Name or id of the resource for this request. |
zoneSetPolicyRequestResource | ZoneSetPolicyRequest The body resource for this request |
Type | Description |
Policy |
setIamPolicyCallable()
public final UnaryCallable<SetIamPolicyDiskRequest,Policy> setIamPolicyCallable()
Sets the access control policy on the specified resource. Replaces any existing policy.
Sample code:
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();
}
Type | Description |
UnaryCallable<SetIamPolicyDiskRequest,Policy> |
setLabelsAsync(SetLabelsDiskRequest request)
public final OperationFuture<Operation,Operation> setLabelsAsync(SetLabelsDiskRequest request)
Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation.
Sample code:
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();
}
Name | Description |
request | SetLabelsDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Operation,Operation> |
setLabelsAsync(String project, String zone, String resource, ZoneSetLabelsRequest zoneSetLabelsRequestResource)
public final OperationFuture<Operation,Operation> setLabelsAsync(String project, String zone, String resource, ZoneSetLabelsRequest zoneSetLabelsRequestResource)
Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation.
Sample code:
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();
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
resource | String Name or id of the resource for this request. |
zoneSetLabelsRequestResource | ZoneSetLabelsRequest The body resource for this request |
Type | Description |
OperationFuture<Operation,Operation> |
setLabelsCallable()
public final UnaryCallable<SetLabelsDiskRequest,Operation> setLabelsCallable()
Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation.
Sample code:
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();
}
Type | Description |
UnaryCallable<SetLabelsDiskRequest,Operation> |
setLabelsOperationCallable()
public final OperationCallable<SetLabelsDiskRequest,Operation,Operation> setLabelsOperationCallable()
Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation.
Sample code:
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
Type | Description |
OperationCallable<SetLabelsDiskRequest,Operation,Operation> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
testIamPermissions(TestIamPermissionsDiskRequest request)
public final TestPermissionsResponse testIamPermissions(TestIamPermissionsDiskRequest request)
Returns permissions that a caller has on the specified resource.
Sample code:
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);
}
Name | Description |
request | TestIamPermissionsDiskRequest The request object containing all of the parameters for the API call. |
Type | Description |
TestPermissionsResponse |
testIamPermissions(String project, String zone, String resource, TestPermissionsRequest testPermissionsRequestResource)
public final TestPermissionsResponse testIamPermissions(String project, String zone, String resource, TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
Sample code:
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);
}
Name | Description |
project | String Project ID for this request. |
zone | String The name of the zone for this request. |
resource | String Name or id of the resource for this request. |
testPermissionsRequestResource | TestPermissionsRequest The body resource for this request |
Type | Description |
TestPermissionsResponse |
testIamPermissionsCallable()
public final UnaryCallable<TestIamPermissionsDiskRequest,TestPermissionsResponse> testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.
Sample code:
try (DisksClient disksClient = DisksClient.create()) {
TestIamPermissionsDiskRequest request =
TestIamPermissionsDiskRequest.newBuilder()
.setProject("project-309310695")
.setResource("resource-341064690")
.setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
.setZone("zone3744684")
.build();
ApiFuture
Type | Description |
UnaryCallable<TestIamPermissionsDiskRequest,TestPermissionsResponse> |