/
wait.ts
35 lines (28 loc) · 979 Bytes
/
wait.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
import {flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'
import BaseCommand, {PrivateLinkDB} from '../../base'
import fetcher from '../../lib/fetcher'
export default class EndpointsWait extends BaseCommand {
static description = 'wait for your Trusted VPC Endpoint to be provisioned'
static args = [
{name: 'database'}
]
static flags = {
app: flags.app({required: true})
}
static examples = [
'$ heroku endpoints:wait postgresql-sushi-12345',
]
async run() {
const {args, flags} = this.parse(EndpointsWait)
const database = args.database || await fetcher(this.heroku, flags.app)
let status
cli.action.start('Waiting for the Trusted VPC Endpoint to be provisioned')
while (status !== 'Operational') {
let {body: res} = await this.heroku.get<PrivateLinkDB>(`/private-link/v0/databases/${database}`, this.heroku.defaults)
status = res.status
await cli.wait(3000)
}
cli.action.stop()
}
}