-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathindex.ts
31 lines (28 loc) · 1.15 KB
/
index.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
import {Command, flags} from '@heroku-cli/command'
import {Args, ux} from '@oclif/core'
import {getAddon} from '../../../lib/pg/fetcher'
import {essentialPlan} from '../../../lib/pg/util'
import pgHost from '../../../lib/pg/host'
import {MaintenanceApiResponse} from '../../../lib/pg/types'
import {nls} from '../../../nls'
export default class Index extends Command {
static topic = 'pg';
static description = 'show current maintenance information';
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
}
static args = {
database: Args.string({description: `${nls('pg:database:arg:description')} ${nls('pg:database:arg:description:default:suffix')}`}),
}
public async run(): Promise<void> {
const {flags, args} = await this.parse(Index)
const {app} = flags
const {database} = args
const db = await getAddon(this.heroku, app, database)
if (essentialPlan(db))
ux.error('pg:maintenance isn’t available for Essential-tier databases.')
const {body: info} = await this.heroku.get<MaintenanceApiResponse>(`/client/v11/databases/${db.id}/maintenance`, {hostname: pgHost()})
ux.log(info.message)
}
}