@Generated(value="by gapic-generator") @BetaApi public class DiskClient extends Object implements BackgroundResource
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 (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
Boolean guestFlush = false;
Snapshot snapshotResource = Snapshot.newBuilder().build();
Operation response = diskClient.createSnapshotDisk(disk, guestFlush, snapshotResource);
}
Note: close() needs to be called on the diskClient 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:
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 DiskSettings to create(). For example:
To customize credentials:
DiskSettings diskSettings =
DiskSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DiskClient diskClient =
DiskClient.create(diskSettings);
To customize the endpoint:
DiskSettings diskSettings =
DiskSettings.newBuilder().setEndpoint(myEndpoint).build();
DiskClient diskClient =
DiskClient.create(diskSettings);
Modifier and Type | Class and Description |
---|---|
static class |
DiskClient.AggregatedListDisksFixedSizeCollection |
static class |
DiskClient.AggregatedListDisksPage |
static class |
DiskClient.AggregatedListDisksPagedResponse |
static class |
DiskClient.ListDisksFixedSizeCollection |
static class |
DiskClient.ListDisksPage |
static class |
DiskClient.ListDisksPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
DiskClient(DiskSettings settings)
Constructs an instance of DiskClient, using the given settings.
|
protected |
DiskClient(DiskStub stub) |
Modifier and Type | Method and Description |
---|---|
DiskClient.AggregatedListDisksPagedResponse |
aggregatedListDisks(AggregatedListDisksHttpRequest request)
Retrieves an aggregated list of persistent disks.
|
DiskClient.AggregatedListDisksPagedResponse |
aggregatedListDisks(ProjectName project)
Retrieves an aggregated list of persistent disks.
|
DiskClient.AggregatedListDisksPagedResponse |
aggregatedListDisks(String project)
Retrieves an aggregated list of persistent disks.
|
UnaryCallable<AggregatedListDisksHttpRequest,DiskAggregatedList> |
aggregatedListDisksCallable()
Retrieves an aggregated list of persistent disks.
|
UnaryCallable<AggregatedListDisksHttpRequest,DiskClient.AggregatedListDisksPagedResponse> |
aggregatedListDisksPagedCallable()
Retrieves an aggregated list of persistent disks.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static DiskClient |
create()
Constructs an instance of DiskClient with default settings.
|
static DiskClient |
create(DiskSettings settings)
Constructs an instance of DiskClient, using the given settings.
|
static DiskClient |
create(DiskStub stub)
Constructs an instance of DiskClient, using the given stub for making calls.
|
Operation |
createSnapshotDisk(CreateSnapshotDiskHttpRequest request)
Creates a snapshot of a specified persistent disk.
|
Operation |
createSnapshotDisk(ProjectZoneDiskName disk,
Boolean guestFlush,
Snapshot snapshotResource)
Creates a snapshot of a specified persistent disk.
|
Operation |
createSnapshotDisk(String disk,
Boolean guestFlush,
Snapshot snapshotResource)
Creates a snapshot of a specified persistent disk.
|
UnaryCallable<CreateSnapshotDiskHttpRequest,Operation> |
createSnapshotDiskCallable()
Creates a snapshot of a specified persistent disk.
|
Operation |
deleteDisk(DeleteDiskHttpRequest request)
Deletes the specified persistent disk.
|
Operation |
deleteDisk(ProjectZoneDiskName disk)
Deletes the specified persistent disk.
|
Operation |
deleteDisk(String disk)
Deletes the specified persistent disk.
|
UnaryCallable<DeleteDiskHttpRequest,Operation> |
deleteDiskCallable()
Deletes the specified persistent disk.
|
Disk |
getDisk(GetDiskHttpRequest request)
Returns a specified persistent disk.
|
Disk |
getDisk(ProjectZoneDiskName disk)
Returns a specified persistent disk.
|
Disk |
getDisk(String disk)
Returns a specified persistent disk.
|
UnaryCallable<GetDiskHttpRequest,Disk> |
getDiskCallable()
Returns a specified persistent disk.
|
Policy |
getIamPolicyDisk(GetIamPolicyDiskHttpRequest request)
Gets the access control policy for a resource.
|
Policy |
getIamPolicyDisk(ProjectZoneDiskResourceName resource)
Gets the access control policy for a resource.
|
Policy |
getIamPolicyDisk(String resource)
Gets the access control policy for a resource.
|
UnaryCallable<GetIamPolicyDiskHttpRequest,Policy> |
getIamPolicyDiskCallable()
Gets the access control policy for a resource.
|
DiskSettings |
getSettings() |
DiskStub |
getStub() |
Operation |
insertDisk(InsertDiskHttpRequest request)
Creates a persistent disk in the specified project using the data in the request.
|
Operation |
insertDisk(ProjectZoneName zone,
Disk diskResource)
Creates a persistent disk in the specified project using the data in the request.
|
Operation |
insertDisk(String zone,
Disk diskResource)
Creates a persistent disk in the specified project using the data in the request.
|
UnaryCallable<InsertDiskHttpRequest,Operation> |
insertDiskCallable()
Creates a persistent disk in the specified project using the data in the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
DiskClient.ListDisksPagedResponse |
listDisks(ListDisksHttpRequest request)
Retrieves a list of persistent disks contained within the specified zone.
|
DiskClient.ListDisksPagedResponse |
listDisks(ProjectZoneName zone)
Retrieves a list of persistent disks contained within the specified zone.
|
DiskClient.ListDisksPagedResponse |
listDisks(String zone)
Retrieves a list of persistent disks contained within the specified zone.
|
UnaryCallable<ListDisksHttpRequest,DiskList> |
listDisksCallable()
Retrieves a list of persistent disks contained within the specified zone.
|
UnaryCallable<ListDisksHttpRequest,DiskClient.ListDisksPagedResponse> |
listDisksPagedCallable()
Retrieves a list of persistent disks contained within the specified zone.
|
Operation |
resizeDisk(ProjectZoneDiskName disk,
DisksResizeRequest disksResizeRequestResource)
Resizes the specified persistent disk.
|
Operation |
resizeDisk(ResizeDiskHttpRequest request)
Resizes the specified persistent disk.
|
Operation |
resizeDisk(String disk,
DisksResizeRequest disksResizeRequestResource)
Resizes the specified persistent disk.
|
UnaryCallable<ResizeDiskHttpRequest,Operation> |
resizeDiskCallable()
Resizes the specified persistent disk.
|
Policy |
setIamPolicyDisk(ProjectZoneDiskResourceName resource,
ZoneSetPolicyRequest zoneSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicyDisk(SetIamPolicyDiskHttpRequest request)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicyDisk(String resource,
ZoneSetPolicyRequest zoneSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
UnaryCallable<SetIamPolicyDiskHttpRequest,Policy> |
setIamPolicyDiskCallable()
Sets the access control policy on the specified resource.
|
Operation |
setLabelsDisk(ProjectZoneDiskResourceName resource,
ZoneSetLabelsRequest zoneSetLabelsRequestResource)
Sets the labels on a disk.
|
Operation |
setLabelsDisk(SetLabelsDiskHttpRequest request)
Sets the labels on a disk.
|
Operation |
setLabelsDisk(String resource,
ZoneSetLabelsRequest zoneSetLabelsRequestResource)
Sets the labels on a disk.
|
UnaryCallable<SetLabelsDiskHttpRequest,Operation> |
setLabelsDiskCallable()
Sets the labels on a disk.
|
void |
shutdown() |
void |
shutdownNow() |
TestPermissionsResponse |
testIamPermissionsDisk(ProjectZoneDiskResourceName resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsDisk(String resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsDisk(TestIamPermissionsDiskHttpRequest request)
Returns permissions that a caller has on the specified resource.
|
UnaryCallable<TestIamPermissionsDiskHttpRequest,TestPermissionsResponse> |
testIamPermissionsDiskCallable()
Returns permissions that a caller has on the specified resource.
|
protected DiskClient(DiskSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected DiskClient(DiskStub stub)
public static final DiskClient create() throws IOException
IOException
public static final DiskClient create(DiskSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final DiskClient create(DiskStub stub)
public final DiskSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public DiskStub getStub()
@BetaApi public final DiskClient.AggregatedListDisksPagedResponse aggregatedListDisks(ProjectName project)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (DisksScopedList element : diskClient.aggregatedListDisks(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final DiskClient.AggregatedListDisksPagedResponse aggregatedListDisks(String project)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (DisksScopedList element : diskClient.aggregatedListDisks(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final DiskClient.AggregatedListDisksPagedResponse aggregatedListDisks(AggregatedListDisksHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListDisksHttpRequest request = AggregatedListDisksHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (DisksScopedList element : diskClient.aggregatedListDisks(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<AggregatedListDisksHttpRequest,DiskClient.AggregatedListDisksPagedResponse> aggregatedListDisksPagedCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListDisksHttpRequest request = AggregatedListDisksHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListDisksPagedResponse> future = diskClient.aggregatedListDisksPagedCallable().futureCall(request);
// Do something
for (DisksScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<AggregatedListDisksHttpRequest,DiskAggregatedList> aggregatedListDisksCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListDisksHttpRequest request = AggregatedListDisksHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
DiskAggregatedList response = diskClient.aggregatedListDisksCallable().call(request);
for (DisksScopedList element : response.getItemsMap()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Operation createSnapshotDisk(ProjectZoneDiskName disk, Boolean guestFlush, Snapshot snapshotResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
Boolean guestFlush = false;
Snapshot snapshotResource = Snapshot.newBuilder().build();
Operation response = diskClient.createSnapshotDisk(disk, guestFlush, snapshotResource);
}
disk
- Name of the persistent disk to snapshot.guestFlush
- snapshotResource
- A persistent disk snapshot resource. (== resource_for beta.snapshots
==) (== resource_for v1.snapshots ==)ApiException
- if the remote call fails@BetaApi public final Operation createSnapshotDisk(String disk, Boolean guestFlush, Snapshot snapshotResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
Boolean guestFlush = false;
Snapshot snapshotResource = Snapshot.newBuilder().build();
Operation response = diskClient.createSnapshotDisk(disk.toString(), guestFlush, snapshotResource);
}
disk
- Name of the persistent disk to snapshot.guestFlush
- snapshotResource
- A persistent disk snapshot resource. (== resource_for beta.snapshots
==) (== resource_for v1.snapshots ==)ApiException
- if the remote call fails@BetaApi public final Operation createSnapshotDisk(CreateSnapshotDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedDisk = ProjectZoneDiskName.format("[PROJECT]", "[ZONE]", "[DISK]");
Boolean guestFlush = false;
Snapshot snapshotResource = Snapshot.newBuilder().build();
CreateSnapshotDiskHttpRequest request = CreateSnapshotDiskHttpRequest.newBuilder()
.setDisk(formattedDisk)
.setGuestFlush(guestFlush)
.setSnapshotResource(snapshotResource)
.build();
Operation response = diskClient.createSnapshotDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<CreateSnapshotDiskHttpRequest,Operation> createSnapshotDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedDisk = ProjectZoneDiskName.format("[PROJECT]", "[ZONE]", "[DISK]");
Boolean guestFlush = false;
Snapshot snapshotResource = Snapshot.newBuilder().build();
CreateSnapshotDiskHttpRequest request = CreateSnapshotDiskHttpRequest.newBuilder()
.setDisk(formattedDisk)
.setGuestFlush(guestFlush)
.setSnapshotResource(snapshotResource)
.build();
ApiFuture<Operation> future = diskClient.createSnapshotDiskCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation deleteDisk(ProjectZoneDiskName disk)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
Operation response = diskClient.deleteDisk(disk);
}
disk
- Name of the persistent disk to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteDisk(String disk)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
Operation response = diskClient.deleteDisk(disk.toString());
}
disk
- Name of the persistent disk to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteDisk(DeleteDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedDisk = ProjectZoneDiskName.format("[PROJECT]", "[ZONE]", "[DISK]");
DeleteDiskHttpRequest request = DeleteDiskHttpRequest.newBuilder()
.setDisk(formattedDisk)
.build();
Operation response = diskClient.deleteDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteDiskHttpRequest,Operation> deleteDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedDisk = ProjectZoneDiskName.format("[PROJECT]", "[ZONE]", "[DISK]");
DeleteDiskHttpRequest request = DeleteDiskHttpRequest.newBuilder()
.setDisk(formattedDisk)
.build();
ApiFuture<Operation> future = diskClient.deleteDiskCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Disk getDisk(ProjectZoneDiskName disk)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
Disk response = diskClient.getDisk(disk);
}
disk
- Name of the persistent disk to return.ApiException
- if the remote call fails@BetaApi public final Disk getDisk(String disk)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
Disk response = diskClient.getDisk(disk.toString());
}
disk
- Name of the persistent disk to return.ApiException
- if the remote call fails@BetaApi public final Disk getDisk(GetDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedDisk = ProjectZoneDiskName.format("[PROJECT]", "[ZONE]", "[DISK]");
GetDiskHttpRequest request = GetDiskHttpRequest.newBuilder()
.setDisk(formattedDisk)
.build();
Disk response = diskClient.getDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetDiskHttpRequest,Disk> getDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedDisk = ProjectZoneDiskName.format("[PROJECT]", "[ZONE]", "[DISK]");
GetDiskHttpRequest request = GetDiskHttpRequest.newBuilder()
.setDisk(formattedDisk)
.build();
ApiFuture<Disk> future = diskClient.getDiskCallable().futureCall(request);
// Do something
Disk response = future.get();
}
@BetaApi public final Policy getIamPolicyDisk(ProjectZoneDiskResourceName resource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskResourceName resource = ProjectZoneDiskResourceName.of("[PROJECT]", "[ZONE]", "[RESOURCE]");
Policy response = diskClient.getIamPolicyDisk(resource);
}
resource
- Name or id of the resource for this request.ApiException
- if the remote call fails@BetaApi public final Policy getIamPolicyDisk(String resource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskResourceName resource = ProjectZoneDiskResourceName.of("[PROJECT]", "[ZONE]", "[RESOURCE]");
Policy response = diskClient.getIamPolicyDisk(resource.toString());
}
resource
- Name or id of the resource for this request.ApiException
- if the remote call fails@BetaApi public final Policy getIamPolicyDisk(GetIamPolicyDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedResource = ProjectZoneDiskResourceName.format("[PROJECT]", "[ZONE]", "[RESOURCE]");
GetIamPolicyDiskHttpRequest request = GetIamPolicyDiskHttpRequest.newBuilder()
.setResource(formattedResource)
.build();
Policy response = diskClient.getIamPolicyDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetIamPolicyDiskHttpRequest,Policy> getIamPolicyDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedResource = ProjectZoneDiskResourceName.format("[PROJECT]", "[ZONE]", "[RESOURCE]");
GetIamPolicyDiskHttpRequest request = GetIamPolicyDiskHttpRequest.newBuilder()
.setResource(formattedResource)
.build();
ApiFuture<Policy> future = diskClient.getIamPolicyDiskCallable().futureCall(request);
// Do something
Policy response = future.get();
}
@BetaApi public final Operation insertDisk(ProjectZoneName zone, Disk diskResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
Disk diskResource = Disk.newBuilder().build();
Operation response = diskClient.insertDisk(zone, diskResource);
}
zone
- The name of the zone for this request.diskResource
- A Disk resource. (== resource_for beta.disks ==) (== resource_for v1.disks
==)ApiException
- if the remote call fails@BetaApi public final Operation insertDisk(String zone, Disk diskResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
Disk diskResource = Disk.newBuilder().build();
Operation response = diskClient.insertDisk(zone.toString(), diskResource);
}
zone
- The name of the zone for this request.diskResource
- A Disk resource. (== resource_for beta.disks ==) (== resource_for v1.disks
==)ApiException
- if the remote call fails@BetaApi public final Operation insertDisk(InsertDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
Disk diskResource = Disk.newBuilder().build();
InsertDiskHttpRequest request = InsertDiskHttpRequest.newBuilder()
.setZone(formattedZone)
.setDiskResource(diskResource)
.build();
Operation response = diskClient.insertDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertDiskHttpRequest,Operation> insertDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
Disk diskResource = Disk.newBuilder().build();
InsertDiskHttpRequest request = InsertDiskHttpRequest.newBuilder()
.setZone(formattedZone)
.setDiskResource(diskResource)
.build();
ApiFuture<Operation> future = diskClient.insertDiskCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final DiskClient.ListDisksPagedResponse listDisks(ProjectZoneName zone)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (Disk element : diskClient.listDisks(zone).iterateAll()) {
// doThingsWith(element);
}
}
zone
- The name of the zone for this request.ApiException
- if the remote call fails@BetaApi public final DiskClient.ListDisksPagedResponse listDisks(String zone)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (Disk element : diskClient.listDisks(zone.toString()).iterateAll()) {
// doThingsWith(element);
}
}
zone
- The name of the zone for this request.ApiException
- if the remote call fails@BetaApi public final DiskClient.ListDisksPagedResponse listDisks(ListDisksHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListDisksHttpRequest request = ListDisksHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
for (Disk element : diskClient.listDisks(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<ListDisksHttpRequest,DiskClient.ListDisksPagedResponse> listDisksPagedCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListDisksHttpRequest request = ListDisksHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
ApiFuture<ListDisksPagedResponse> future = diskClient.listDisksPagedCallable().futureCall(request);
// Do something
for (Disk element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListDisksHttpRequest,DiskList> listDisksCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListDisksHttpRequest request = ListDisksHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
while (true) {
DiskList response = diskClient.listDisksCallable().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;
}
}
}
@BetaApi public final Operation resizeDisk(ProjectZoneDiskName disk, DisksResizeRequest disksResizeRequestResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
DisksResizeRequest disksResizeRequestResource = DisksResizeRequest.newBuilder().build();
Operation response = diskClient.resizeDisk(disk, disksResizeRequestResource);
}
disk
- The name of the persistent disk.disksResizeRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation resizeDisk(String disk, DisksResizeRequest disksResizeRequestResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskName disk = ProjectZoneDiskName.of("[PROJECT]", "[ZONE]", "[DISK]");
DisksResizeRequest disksResizeRequestResource = DisksResizeRequest.newBuilder().build();
Operation response = diskClient.resizeDisk(disk.toString(), disksResizeRequestResource);
}
disk
- The name of the persistent disk.disksResizeRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation resizeDisk(ResizeDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedDisk = ProjectZoneDiskName.format("[PROJECT]", "[ZONE]", "[DISK]");
DisksResizeRequest disksResizeRequestResource = DisksResizeRequest.newBuilder().build();
ResizeDiskHttpRequest request = ResizeDiskHttpRequest.newBuilder()
.setDisk(formattedDisk)
.setDisksResizeRequestResource(disksResizeRequestResource)
.build();
Operation response = diskClient.resizeDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<ResizeDiskHttpRequest,Operation> resizeDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedDisk = ProjectZoneDiskName.format("[PROJECT]", "[ZONE]", "[DISK]");
DisksResizeRequest disksResizeRequestResource = DisksResizeRequest.newBuilder().build();
ResizeDiskHttpRequest request = ResizeDiskHttpRequest.newBuilder()
.setDisk(formattedDisk)
.setDisksResizeRequestResource(disksResizeRequestResource)
.build();
ApiFuture<Operation> future = diskClient.resizeDiskCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Policy setIamPolicyDisk(ProjectZoneDiskResourceName resource, ZoneSetPolicyRequest zoneSetPolicyRequestResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskResourceName resource = ProjectZoneDiskResourceName.of("[PROJECT]", "[ZONE]", "[RESOURCE]");
ZoneSetPolicyRequest zoneSetPolicyRequestResource = ZoneSetPolicyRequest.newBuilder().build();
Policy response = diskClient.setIamPolicyDisk(resource, zoneSetPolicyRequestResource);
}
resource
- Name or id of the resource for this request.zoneSetPolicyRequestResource
- ApiException
- if the remote call fails@BetaApi public final Policy setIamPolicyDisk(String resource, ZoneSetPolicyRequest zoneSetPolicyRequestResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskResourceName resource = ProjectZoneDiskResourceName.of("[PROJECT]", "[ZONE]", "[RESOURCE]");
ZoneSetPolicyRequest zoneSetPolicyRequestResource = ZoneSetPolicyRequest.newBuilder().build();
Policy response = diskClient.setIamPolicyDisk(resource.toString(), zoneSetPolicyRequestResource);
}
resource
- Name or id of the resource for this request.zoneSetPolicyRequestResource
- ApiException
- if the remote call fails@BetaApi public final Policy setIamPolicyDisk(SetIamPolicyDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedResource = ProjectZoneDiskResourceName.format("[PROJECT]", "[ZONE]", "[RESOURCE]");
ZoneSetPolicyRequest zoneSetPolicyRequestResource = ZoneSetPolicyRequest.newBuilder().build();
SetIamPolicyDiskHttpRequest request = SetIamPolicyDiskHttpRequest.newBuilder()
.setResource(formattedResource)
.setZoneSetPolicyRequestResource(zoneSetPolicyRequestResource)
.build();
Policy response = diskClient.setIamPolicyDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<SetIamPolicyDiskHttpRequest,Policy> setIamPolicyDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedResource = ProjectZoneDiskResourceName.format("[PROJECT]", "[ZONE]", "[RESOURCE]");
ZoneSetPolicyRequest zoneSetPolicyRequestResource = ZoneSetPolicyRequest.newBuilder().build();
SetIamPolicyDiskHttpRequest request = SetIamPolicyDiskHttpRequest.newBuilder()
.setResource(formattedResource)
.setZoneSetPolicyRequestResource(zoneSetPolicyRequestResource)
.build();
ApiFuture<Policy> future = diskClient.setIamPolicyDiskCallable().futureCall(request);
// Do something
Policy response = future.get();
}
@BetaApi public final Operation setLabelsDisk(ProjectZoneDiskResourceName resource, ZoneSetLabelsRequest zoneSetLabelsRequestResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskResourceName resource = ProjectZoneDiskResourceName.of("[PROJECT]", "[ZONE]", "[RESOURCE]");
ZoneSetLabelsRequest zoneSetLabelsRequestResource = ZoneSetLabelsRequest.newBuilder().build();
Operation response = diskClient.setLabelsDisk(resource, zoneSetLabelsRequestResource);
}
resource
- Name or id of the resource for this request.zoneSetLabelsRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation setLabelsDisk(String resource, ZoneSetLabelsRequest zoneSetLabelsRequestResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskResourceName resource = ProjectZoneDiskResourceName.of("[PROJECT]", "[ZONE]", "[RESOURCE]");
ZoneSetLabelsRequest zoneSetLabelsRequestResource = ZoneSetLabelsRequest.newBuilder().build();
Operation response = diskClient.setLabelsDisk(resource.toString(), zoneSetLabelsRequestResource);
}
resource
- Name or id of the resource for this request.zoneSetLabelsRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation setLabelsDisk(SetLabelsDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedResource = ProjectZoneDiskResourceName.format("[PROJECT]", "[ZONE]", "[RESOURCE]");
ZoneSetLabelsRequest zoneSetLabelsRequestResource = ZoneSetLabelsRequest.newBuilder().build();
SetLabelsDiskHttpRequest request = SetLabelsDiskHttpRequest.newBuilder()
.setResource(formattedResource)
.setZoneSetLabelsRequestResource(zoneSetLabelsRequestResource)
.build();
Operation response = diskClient.setLabelsDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<SetLabelsDiskHttpRequest,Operation> setLabelsDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedResource = ProjectZoneDiskResourceName.format("[PROJECT]", "[ZONE]", "[RESOURCE]");
ZoneSetLabelsRequest zoneSetLabelsRequestResource = ZoneSetLabelsRequest.newBuilder().build();
SetLabelsDiskHttpRequest request = SetLabelsDiskHttpRequest.newBuilder()
.setResource(formattedResource)
.setZoneSetLabelsRequestResource(zoneSetLabelsRequestResource)
.build();
ApiFuture<Operation> future = diskClient.setLabelsDiskCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final TestPermissionsResponse testIamPermissionsDisk(ProjectZoneDiskResourceName resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskResourceName resource = ProjectZoneDiskResourceName.of("[PROJECT]", "[ZONE]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = diskClient.testIamPermissionsDisk(resource, testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsDisk(String resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
ProjectZoneDiskResourceName resource = ProjectZoneDiskResourceName.of("[PROJECT]", "[ZONE]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = diskClient.testIamPermissionsDisk(resource.toString(), testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsDisk(TestIamPermissionsDiskHttpRequest request)
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedResource = ProjectZoneDiskResourceName.format("[PROJECT]", "[ZONE]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsDiskHttpRequest request = TestIamPermissionsDiskHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
TestPermissionsResponse response = diskClient.testIamPermissionsDisk(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<TestIamPermissionsDiskHttpRequest,TestPermissionsResponse> testIamPermissionsDiskCallable()
Sample code:
try (DiskClient diskClient = DiskClient.create()) {
String formattedResource = ProjectZoneDiskResourceName.format("[PROJECT]", "[ZONE]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsDiskHttpRequest request = TestIamPermissionsDiskHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
ApiFuture<TestPermissionsResponse> future = diskClient.testIamPermissionsDiskCallable().futureCall(request);
// Do something
TestPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.