-
Notifications
You must be signed in to change notification settings - Fork 17
/
topics_destroy.js
64 lines (55 loc) · 1.92 KB
/
topics_destroy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict'
let cli = require('heroku-cli-util')
let co = require('co')
let deprecated = require('../lib/shared').deprecated
let withCluster = require('../lib/clusters').withCluster
let request = require('../lib/clusters').request
const VERSION = 'v0'
function * destroyTopic (context, heroku) {
yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
yield cli.confirmApp(context.app, context.flags.confirm,
`This command will affect the cluster: ${addon.name}, which is on ${context.app}`)
yield cli.action(`Deleting topic ${context.args.TOPIC}`, co(function * () {
const topicName = context.args.TOPIC
return yield request(heroku, {
method: 'DELETE',
body: {
topic_name: topicName
},
path: `/data/kafka/${VERSION}/clusters/${addon.id}/topics/${topicName}`
})
}))
cli.log('Your topic has been marked for deletion, and will be removed from the cluster shortly')
})
}
let cmd = {
topic: 'kafka',
command: 'topics:destroy',
description: 'deletes a topic in Kafka',
help: `
Deletes a topic in Kafka.
Note that topics are deleted asynchronously, so even though this command has returned,
a topic may still exist.
Examples:
$ heroku kafka:topics:destroy page-visits
$ heroku kafka:topics:destroy page-visits HEROKU_KAFKA_BROWN_URL
`,
needsApp: true,
needsAuth: true,
args: [
{ name: 'TOPIC' },
{ name: 'CLUSTER', optional: true }
],
flags: [
{ name: 'confirm',
description: 'pass the app name to skip the manual confirmation prompt',
hasValue: true }
],
run: cli.command({preauth: true}, co.wrap(destroyTopic))
}
module.exports = {
cmd,
deprecated: Object.assign({}, cmd, { command: 'delete',
hidden: true,
run: cli.command(co.wrap(deprecated(destroyTopic, cmd.command))) })
}