-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathremove.ts
45 lines (39 loc) · 1.57 KB
/
remove.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
import {flags} from '@heroku-cli/command'
import {Args, ux} from '@oclif/core'
import BaseCommand from '../../../../base'
import fetcher from '../../../../lib/fetcher'
export default class Remove extends BaseCommand {
static description = 'remove an allowed account from your privatelink endpoint'
static hiddenAliases = ['pg:privatelink:access:remove', 'kafka:privatelink:access:remove', 'redis:privatelink:access:remove']
static args = {
database: Args.string({required: true}),
}
static flags = {
'aws-account-id': flags.string({
char: 'i',
description: 'AWS account id to use',
required: true,
multiple: true,
}),
app: flags.app({required: true}),
remote: flags.remote(),
}
static examples = [
'$ heroku data:privatelink:access:remove postgresql-sushi-12345 --aws-account-id 123456789012:user/xyz --app my-app',
'$ heroku data:privatelink:access:remove postgresql-sushi-12345 --aws-account-id 123456789012:user/abc --aws-account-id 123456789012:user/xyz --app my-app',
]
public async run(): Promise<void> {
const {args, flags} = await this.parse(Remove)
const database = await fetcher(this.heroku, args.database, flags.app)
const {'aws-account-id': account_ids} = flags
const accountFormatted = account_ids.length > 1 ? 'accounts' : 'account'
ux.action.start(`Removing ${accountFormatted}`)
await this.shogun.patch(`/private-link/v0/databases/${database}/allowed_accounts`, {
...this.shogun.defaults,
body: {
allowed_accounts: account_ids,
},
})
ux.action.stop()
}
}