Search in sources :

Example 1 with DeleteSubscriptionRequest

use of com.google.pubsub.v1.DeleteSubscriptionRequest in project beam by apache.

the class PubsubGrpcClient method deleteSubscription.

@Override
public void deleteSubscription(SubscriptionPath subscription) throws IOException {
    DeleteSubscriptionRequest request = DeleteSubscriptionRequest.newBuilder().setSubscription(subscription.getPath()).build();
    // ignore Empty result.
    subscriberStub().deleteSubscription(request);
}
Also used : DeleteSubscriptionRequest(com.google.pubsub.v1.DeleteSubscriptionRequest)

Example 2 with DeleteSubscriptionRequest

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

the class SubscriptionAdminClient method deleteSubscription.

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
   * Deletes an existing subscription. All messages retained in the subscription are immediately
   * dropped. Calls to `Pull` after deletion will return `NOT_FOUND`. After a subscription is
   * deleted, a new one may be created with the same name, but the new one has no association with
   * the old subscription or its topic unless the same topic is specified.
   *
   * <p>Sample code:
   *
   * <pre><code>
   * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
   *   SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
   *   subscriptionAdminClient.deleteSubscription(subscription);
   * }
   * </code></pre>
   *
   * @param subscription The subscription to delete. Format is
   *     `projects/{project}/subscriptions/{sub}`.
   * @throws com.google.api.gax.grpc.ApiException if the remote call fails
   */
public final void deleteSubscription(SubscriptionName subscription) {
    DeleteSubscriptionRequest request = DeleteSubscriptionRequest.newBuilder().setSubscriptionWithSubscriptionName(subscription).build();
    deleteSubscription(request);
}
Also used : DeleteSubscriptionRequest(com.google.pubsub.v1.DeleteSubscriptionRequest)

Example 3 with DeleteSubscriptionRequest

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

the class SubscriptionAdminClientTest method deleteSubscriptionTest.

@Test
@SuppressWarnings("all")
public void deleteSubscriptionTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockSubscriber.addResponse(expectedResponse);
    SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
    client.deleteSubscription(subscription);
    List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteSubscriptionRequest actualRequest = (DeleteSubscriptionRequest) actualRequests.get(0);
    Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
}
Also used : Empty(com.google.protobuf.Empty) SubscriptionName(com.google.pubsub.v1.SubscriptionName) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) DeleteSubscriptionRequest(com.google.pubsub.v1.DeleteSubscriptionRequest) Test(org.junit.Test)

Aggregations

DeleteSubscriptionRequest (com.google.pubsub.v1.DeleteSubscriptionRequest)3 Empty (com.google.protobuf.Empty)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 SubscriptionName (com.google.pubsub.v1.SubscriptionName)1 Test (org.junit.Test)1