This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
info.ts
76 lines (61 loc) · 2.02 KB
/
info.ts
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
65
66
67
68
69
70
71
72
73
74
75
76
import {flags} from '@heroku-cli/command'
import color from '@heroku-cli/color'
import cli from 'cli-ux'
import BaseCommand, {PostgresConnector} from '../../../lib/base'
export default class ConnectorsInfo extends BaseCommand {
static description = 'Get information about a Data Connector\nRead more about this feature at https://devcenter.heroku.com/articles/heroku-data-connectors'
static examples = [
'$ heroku data:connectors:info gentle-connector-1234',
'$ heroku data:connectors:info gentle-connector-1234 --json',
]
static flags = {
json: flags.boolean({
description: 'Return the results as JSON',
}),
}
static args = [
{
name: 'connector',
},
]
async run() {
const {args, flags} = this.parse(ConnectorsInfo)
const connector = args.connector
const {body: res} = await this.shogun.get<PostgresConnector>(
`/data/cdc/v0/connectors/${connector}`,
this.shogun.defaults
)
if (flags.json) {
cli.styledJSON(res)
return
}
if (res.status === 'creating') {
this.log(`The Data Connector is now being provisioned for ${color.cyan(connector)}.`)
this.log(`Run ${color.cyan(`heroku data:connectors:wait ${res.name}`)} to check the creation process.`)
return
}
cli.styledHeader(`Data Connector status for ${color.cyan(connector)}`)
cli.styledObject({
Lag: res.lag,
Status: res.status,
'Service Name': res.uuid || 'Provisioning',
})
if (res.topics && res.topics.length > 0) {
this.log()
cli.styledHeader('Configuration')
cli.table(res.topics, {
table_name: {header: 'Table Name'},
topic_name: {header: 'Topic Name'},
})
}
if (res.excluded_columns && res.excluded_columns.length > 0) {
this.log()
this.log(color.bold('Excluded Columns'))
res.excluded_columns.forEach(column => this.log(column))
}
this.log()
if (res.status === 'available') {
this.log(`Your Data Connector is now ${color.green('available')}.`)
}
}
}