Search in sources :

Example 1 with DeleteSnapshotRequest

use of com.google.pubsub.v1.DeleteSnapshotRequest in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClient method deleteSnapshot.

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
   * Removes an existing snapshot. All messages retained in the snapshot are immediately dropped.
   * After a snapshot is deleted, a new one may be created with the same name, but the new one has
   * no association with the old snapshot or its subscription, unless the same subscription is
   * specified.
   *
   * <p>Sample code:
   *
   * <pre><code>
   * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
   *   SnapshotName snapshot = SnapshotName.create("[PROJECT]", "[SNAPSHOT]");
   *   subscriptionAdminClient.deleteSnapshot(snapshot);
   * }
   * </code></pre>
   *
   * @param snapshot The name of the snapshot to delete. Format is
   *     `projects/{project}/snapshots/{snap}`.
   * @throws com.google.api.gax.grpc.ApiException if the remote call fails
   */
public final void deleteSnapshot(SnapshotName snapshot) {
    DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setSnapshotWithSnapshotName(snapshot).build();
    deleteSnapshot(request);
}
Also used : DeleteSnapshotRequest(com.google.pubsub.v1.DeleteSnapshotRequest)

Example 2 with DeleteSnapshotRequest

use of com.google.pubsub.v1.DeleteSnapshotRequest in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method deleteSnapshotTest.

@Test
@SuppressWarnings("all")
public void deleteSnapshotTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockSubscriber.addResponse(expectedResponse);
    SnapshotName snapshot = SnapshotName.create("[PROJECT]", "[SNAPSHOT]");
    client.deleteSnapshot(snapshot);
    List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteSnapshotRequest actualRequest = (DeleteSnapshotRequest) actualRequests.get(0);
    Assert.assertEquals(snapshot, actualRequest.getSnapshotAsSnapshotName());
}
Also used : Empty(com.google.protobuf.Empty) DeleteSnapshotRequest(com.google.pubsub.v1.DeleteSnapshotRequest) SnapshotName(com.google.pubsub.v1.SnapshotName) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

DeleteSnapshotRequest (com.google.pubsub.v1.DeleteSnapshotRequest)2 Empty (com.google.protobuf.Empty)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 SnapshotName (com.google.pubsub.v1.SnapshotName)1 Test (org.junit.Test)1