Search in sources :

Example 1 with GetSnapshotRequest

use of com.google.bigtable.admin.v2.GetSnapshotRequest 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 2 with GetSnapshotRequest

use of com.google.bigtable.admin.v2.GetSnapshotRequest 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 3 with GetSnapshotRequest

use of com.google.bigtable.admin.v2.GetSnapshotRequest 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)

Example 4 with GetSnapshotRequest

use of com.google.bigtable.admin.v2.GetSnapshotRequest in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method getSnapshotTest2.

@Test
public void getSnapshotTest2() throws Exception {
    Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    Snapshot actualResponse = client.getSnapshot(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSnapshotRequest actualRequest = ((GetSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.bigtable.admin.v2.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) GetSnapshotRequest(com.google.bigtable.admin.v2.GetSnapshotRequest) Test(org.junit.Test)

Example 5 with GetSnapshotRequest

use of com.google.bigtable.admin.v2.GetSnapshotRequest in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method getSnapshotTest.

@Test
public void getSnapshotTest() throws Exception {
    Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
    Snapshot actualResponse = client.getSnapshot(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSnapshotRequest actualRequest = ((GetSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.bigtable.admin.v2.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) GetSnapshotRequest(com.google.bigtable.admin.v2.GetSnapshotRequest) SnapshotName(com.google.bigtable.admin.v2.SnapshotName) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)6 GetSnapshotRequest (com.google.pubsub.v1.GetSnapshotRequest)6 Snapshot (com.google.pubsub.v1.Snapshot)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)4 ByteString (com.google.protobuf.ByteString)3 GetSnapshotRequest (com.google.bigtable.admin.v2.GetSnapshotRequest)2 Snapshot (com.google.bigtable.admin.v2.Snapshot)2 SubscriptionAdminClient (com.google.cloud.pubsub.v1.SubscriptionAdminClient)2 SnapshotName (com.google.pubsub.v1.SnapshotName)2 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)1