use of com.google.cloud.compute.v1.DisksClient in project java-docs-samples by GoogleCloudPlatform.
the class InstancesAdvancedIT method createSnapshot.
private static Snapshot createSnapshot(Disk srcDisk) throws IOException, InterruptedException, ExecutionException, TimeoutException {
try (SnapshotsClient snapshotsClient = SnapshotsClient.create();
DisksClient disksClient = DisksClient.create()) {
Snapshot snapshot = Snapshot.newBuilder().setName("test-snap-" + UUID.randomUUID()).build();
OperationFuture<Operation, Operation> operation = disksClient.createSnapshotAsync(PROJECT_ID, ZONE, srcDisk.getName(), snapshot);
operation.get(3, TimeUnit.MINUTES);
return snapshotsClient.get(PROJECT_ID, snapshot.getName());
}
}
use of com.google.cloud.compute.v1.DisksClient in project java-docs-samples by GoogleCloudPlatform.
the class InstancesAdvancedIT method createSourceDisk.
private static Disk createSourceDisk() throws IOException, ExecutionException, InterruptedException, TimeoutException {
try (DisksClient disksClient = DisksClient.create()) {
Disk disk = Disk.newBuilder().setSourceImage(getActiveDebian().getSelfLink()).setName("test-disk-" + UUID.randomUUID()).build();
OperationFuture<Operation, Operation> operation = disksClient.insertAsync(PROJECT_ID, ZONE, disk);
// Wait for the operation to complete.
operation.get(3, TimeUnit.MINUTES);
return disksClient.get(PROJECT_ID, ZONE, disk.getName());
}
}
Aggregations