use of com.google.cloud.compute.v1.SnapshotsClient in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method deleteSnapshot.
private static void deleteSnapshot(Snapshot snapshot) throws IOException, InterruptedException, ExecutionException {
try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
OperationFuture<Operation, Operation> operation = snapshotsClient.deleteAsync(PROJECT_ID, snapshot.getName());
operation.get();
}
}
use of com.google.cloud.compute.v1.SnapshotsClient in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method createSnapshot.
private static Snapshot createSnapshot(Disk srcDisk) throws IOException, InterruptedException, ExecutionException {
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();
return snapshotsClient.get(PROJECT_ID, snapshot.getName());
}
}
use of com.google.cloud.compute.v1.SnapshotsClient 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.SnapshotsClient in project java-docs-samples by GoogleCloudPlatform.
the class InstancesAdvancedIT method deleteSnapshot.
private static void deleteSnapshot(Snapshot snapshot) throws IOException, InterruptedException, ExecutionException, TimeoutException {
try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
OperationFuture<Operation, Operation> operation = snapshotsClient.deleteAsync(PROJECT_ID, snapshot.getName());
operation.get(3, TimeUnit.MINUTES);
}
}
Aggregations