Search in sources :

Example 1 with DeleteTopicRequest

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

the class TopicAdminClient method deleteTopic.

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
   * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a
   * topic is deleted, a new topic may be created with the same name; this is an entirely new topic
   * with none of the old configuration or subscriptions. Existing subscriptions to this topic are
   * not deleted, but their `topic` field is set to `_deleted-topic_`.
   *
   * <p>Sample code:
   *
   * <pre><code>
   * try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
   *   TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
   *   topicAdminClient.deleteTopic(topic);
   * }
   * </code></pre>
   *
   * @param topic Name of the topic to delete. Format is `projects/{project}/topics/{topic}`.
   * @throws com.google.api.gax.grpc.ApiException if the remote call fails
   */
public final void deleteTopic(TopicName topic) {
    DeleteTopicRequest request = DeleteTopicRequest.newBuilder().setTopicWithTopicName(topic).build();
    deleteTopic(request);
}
Also used : DeleteTopicRequest(com.google.pubsub.v1.DeleteTopicRequest)

Example 2 with DeleteTopicRequest

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

the class TopicAdminClientTest method deleteTopicTest.

@Test
@SuppressWarnings("all")
public void deleteTopicTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockPublisher.addResponse(expectedResponse);
    TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
    client.deleteTopic(topic);
    List<GeneratedMessageV3> actualRequests = mockPublisher.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteTopicRequest actualRequest = (DeleteTopicRequest) actualRequests.get(0);
    Assert.assertEquals(topic, actualRequest.getTopicAsTopicName());
}
Also used : Empty(com.google.protobuf.Empty) DeleteTopicRequest(com.google.pubsub.v1.DeleteTopicRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) TopicName(com.google.pubsub.v1.TopicName) Test(org.junit.Test)

Example 3 with DeleteTopicRequest

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

the class PubsubGrpcClient method deleteTopic.

@Override
public void deleteTopic(TopicPath topic) throws IOException {
    DeleteTopicRequest request = DeleteTopicRequest.newBuilder().setTopic(topic.getPath()).build();
    // ignore Empty result.
    publisherStub().deleteTopic(request);
}
Also used : DeleteTopicRequest(com.google.pubsub.v1.DeleteTopicRequest)

Aggregations

DeleteTopicRequest (com.google.pubsub.v1.DeleteTopicRequest)3 Empty (com.google.protobuf.Empty)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 TopicName (com.google.pubsub.v1.TopicName)1 Test (org.junit.Test)1