use of com.google.bigtable.admin.v2.Snapshot in project java-pubsub by googleapis.
the class SubscriptionAdminClientTest method updateSnapshotTest.
@Test
public void updateSnapshotTest() 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);
UpdateSnapshotRequest request = UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
Snapshot actualResponse = client.updateSnapshot(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateSnapshotRequest actualRequest = ((UpdateSnapshotRequest) actualRequests.get(0));
Assert.assertEquals(request.getSnapshot(), actualRequest.getSnapshot());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.Snapshot in project java-pubsub by googleapis.
the class SubscriptionAdminClientTest method createSnapshotTest2.
@Test
public void createSnapshotTest2() 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 name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
String subscription = "subscription341203229";
Snapshot actualResponse = client.createSnapshot(name, subscription);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSnapshotRequest actualRequest = ((CreateSnapshotRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(subscription, actualRequest.getSubscription());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.
the class SyncCreateSnapshotStringString method syncCreateSnapshotStringString.
public static void syncCreateSnapshotStringString() throws Exception {
// It may require modifications to work in your environment.
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
String name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString();
String subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString();
Snapshot response = subscriptionAdminClient.createSnapshot(name, subscription);
}
}
use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.
the class SyncCreateSnapshotStringSubscriptionname method syncCreateSnapshotStringSubscriptionname.
public static void syncCreateSnapshotStringSubscriptionname() throws Exception {
// It may require modifications to work in your environment.
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
String name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString();
SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
Snapshot response = subscriptionAdminClient.createSnapshot(name, subscription);
}
}
use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.
the class AsyncUpdateSnapshot method asyncUpdateSnapshot.
public static void asyncUpdateSnapshot() 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();
ApiFuture<Snapshot> future = subscriptionAdminClient.updateSnapshotCallable().futureCall(request);
// Do something.
Snapshot response = future.get();
}
}
Aggregations