Search in sources :

Example 46 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.

the class SyncCreateSnapshotSnapshotnameString method syncCreateSnapshotSnapshotnameString.

public static void syncCreateSnapshotSnapshotnameString() throws Exception {
    // It may require modifications to work in your environment.
    try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
        SnapshotName name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
        String subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString();
        Snapshot response = subscriptionAdminClient.createSnapshot(name, subscription);
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient) SnapshotName(com.google.pubsub.v1.SnapshotName)

Example 47 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.

the class SyncCreateSnapshotSnapshotnameSubscriptionname method syncCreateSnapshotSnapshotnameSubscriptionname.

public static void syncCreateSnapshotSnapshotnameSubscriptionname() throws Exception {
    // It may require modifications to work in your environment.
    try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
        SnapshotName name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
        SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
        Snapshot response = subscriptionAdminClient.createSnapshot(name, subscription);
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient) SubscriptionName(com.google.pubsub.v1.SubscriptionName) SnapshotName(com.google.pubsub.v1.SnapshotName)

Example 48 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.

the class SyncGetSnapshotString method syncGetSnapshotString.

public static void syncGetSnapshotString() throws Exception {
    // It may require modifications to work in your environment.
    try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
        String snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString();
        Snapshot response = subscriptionAdminClient.getSnapshot(snapshot);
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient)

Example 49 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.

the class AsyncListSnapshots method asyncListSnapshots.

public static void asyncListSnapshots() throws Exception {
    // It may require modifications to work in your environment.
    try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
        ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder().setProject(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();
        ApiFuture<Snapshot> future = subscriptionAdminClient.listSnapshotsPagedCallable().futureCall(request);
        // Do something.
        for (Snapshot element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) ListSnapshotsRequest(com.google.pubsub.v1.ListSnapshotsRequest) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient)

Example 50 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.

the class AsyncListSnapshotsPaged method asyncListSnapshotsPaged.

public static void asyncListSnapshotsPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
        ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder().setProject(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();
        while (true) {
            ListSnapshotsResponse response = subscriptionAdminClient.listSnapshotsCallable().call(request);
            for (Snapshot element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) ListSnapshotsRequest(com.google.pubsub.v1.ListSnapshotsRequest) ListSnapshotsResponse(com.google.pubsub.v1.ListSnapshotsResponse) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient)

Aggregations

Test (org.junit.Test)35 Snapshot (com.google.pubsub.v1.Snapshot)34 AbstractMessage (com.google.protobuf.AbstractMessage)29 ByteString (com.google.protobuf.ByteString)21 HashMap (java.util.HashMap)18 SubscriptionAdminClient (com.google.cloud.pubsub.v1.SubscriptionAdminClient)14 CreateSnapshotRequest (com.google.pubsub.v1.CreateSnapshotRequest)11 SnapshotName (com.google.pubsub.v1.SnapshotName)10 Snapshot (com.google.bigtable.admin.v2.Snapshot)8 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)8 ListSnapshotsRequest (com.google.pubsub.v1.ListSnapshotsRequest)7 SubscriptionName (com.google.pubsub.v1.SubscriptionName)7 Operation (com.google.longrunning.Operation)6 GetSnapshotRequest (com.google.pubsub.v1.GetSnapshotRequest)6 ListSnapshotsResponse (com.google.pubsub.v1.ListSnapshotsResponse)6 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 SnapshotTableRequest (com.google.bigtable.admin.v2.SnapshotTableRequest)4 ListSnapshotsPagedResponse (com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse)4 UpdateSnapshotRequest (com.google.pubsub.v1.UpdateSnapshotRequest)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4