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);
}
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());
}
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);
}
Aggregations