fun deleteTopic()

in pubsub/src/main/kotlin/PubSub.kt [177:193]


fun deleteTopic(vararg args: String) { // expects 1 arg: <topic> to delete
    if (args.isEmpty()) {
        error("Bad input: command 'del-topic' expects 1 argument. \n $usage")
    }

    // Your topic ID, eg. "my-topic"
    val topicId = args[0]

    val topic = TopicName.of(projectId, topicId)

    try {
        TopicAdminClient.create().use { topicAdminClient -> topicAdminClient.deleteTopic(topic) }
        println("Topic ${topic.project}:${topic.topic} successfully deleted.")
    } catch (e: IOException) {
        System.err.println("Error deleting topic ${e.message}")
    }
}