Search in sources :

Example 1 with SnapshotsClient

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();
    }
}
Also used : SnapshotsClient(com.google.cloud.compute.v1.SnapshotsClient) Operation(com.google.cloud.compute.v1.Operation)

Example 2 with SnapshotsClient

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());
    }
}
Also used : Snapshot(com.google.cloud.compute.v1.Snapshot) SnapshotsClient(com.google.cloud.compute.v1.SnapshotsClient) Operation(com.google.cloud.compute.v1.Operation) DisksClient(com.google.cloud.compute.v1.DisksClient)

Example 3 with SnapshotsClient

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());
    }
}
Also used : Snapshot(com.google.cloud.compute.v1.Snapshot) SnapshotsClient(com.google.cloud.compute.v1.SnapshotsClient) Operation(com.google.cloud.compute.v1.Operation) DisksClient(com.google.cloud.compute.v1.DisksClient)

Example 4 with SnapshotsClient

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);
    }
}
Also used : SnapshotsClient(com.google.cloud.compute.v1.SnapshotsClient) Operation(com.google.cloud.compute.v1.Operation)

Aggregations

Operation (com.google.cloud.compute.v1.Operation)4 SnapshotsClient (com.google.cloud.compute.v1.SnapshotsClient)4 DisksClient (com.google.cloud.compute.v1.DisksClient)2 Snapshot (com.google.cloud.compute.v1.Snapshot)2