Search in sources :

Example 6 with Snapshot

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

the class SubscriptionAdminClientTest method getSnapshotTest.

@Test
public void getSnapshotTest() throws Exception {
    Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()).setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()).setExpireTime(Timestamp.newBuilder().build()).putAllLabels(new HashMap<String, String>()).build();
    mockSubscriber.addResponse(expectedResponse);
    SnapshotName snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
    Snapshot actualResponse = client.getSnapshot(snapshot);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSnapshotRequest actualRequest = ((GetSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(snapshot.toString(), actualRequest.getSnapshot());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) GetSnapshotRequest(com.google.pubsub.v1.GetSnapshotRequest) SnapshotName(com.google.pubsub.v1.SnapshotName) Test(org.junit.Test)

Example 7 with Snapshot

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

the class SyncUpdateSnapshot method syncUpdateSnapshot.

public static void syncUpdateSnapshot() throws Exception {
    // It may require modifications to work in your environment.
    try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
        UpdateSnapshotRequest request = UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
        Snapshot response = subscriptionAdminClient.updateSnapshot(request);
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient) UpdateSnapshotRequest(com.google.pubsub.v1.UpdateSnapshotRequest)

Example 8 with Snapshot

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

the class SyncGetSnapshot method syncGetSnapshot.

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

Example 9 with Snapshot

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

the class SyncGetSnapshotSnapshotname method syncGetSnapshotSnapshotname.

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

Example 10 with Snapshot

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

the class AsyncGetSnapshot method asyncGetSnapshot.

public static void asyncGetSnapshot() throws Exception {
    // It may require modifications to work in your environment.
    try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
        GetSnapshotRequest request = GetSnapshotRequest.newBuilder().setSnapshot(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()).build();
        ApiFuture<Snapshot> future = subscriptionAdminClient.getSnapshotCallable().futureCall(request);
        // Do something.
        Snapshot response = future.get();
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient) GetSnapshotRequest(com.google.pubsub.v1.GetSnapshotRequest)

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