Search in sources :

Example 41 with Snapshot

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()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) UpdateSnapshotRequest(com.google.pubsub.v1.UpdateSnapshotRequest) Test(org.junit.Test)

Example 42 with Snapshot

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()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) CreateSnapshotRequest(com.google.pubsub.v1.CreateSnapshotRequest) ByteString(com.google.protobuf.ByteString) SnapshotName(com.google.pubsub.v1.SnapshotName) Test(org.junit.Test)

Example 43 with Snapshot

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);
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient)

Example 44 with Snapshot

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);
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient) SubscriptionName(com.google.pubsub.v1.SubscriptionName)

Example 45 with Snapshot

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();
    }
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient) UpdateSnapshotRequest(com.google.pubsub.v1.UpdateSnapshotRequest)

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