-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.ts
43 lines (35 loc) · 1.4 KB
/
get.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
import {ux} from '@oclif/core'
import {commonApiRelatedArgs} from '../../../common/args.js'
import {BaseCommand} from '../../../base-command.js'
import {printFormattedJSON} from '../../../utils/display.js'
import {getDeployments} from '../../../api/deployments.js'
export default class Workflows extends BaseCommand<typeof Workflows> {
public static enableJsonFlag = true
static args = {
...commonApiRelatedArgs,
}
static description = 'Universal Broker - Get Deployments Workflow'
static examples = [`<%= config.bin %> <%= command.id %>`]
async run(): Promise<string> {
try {
this.log('\n' + ux.colorize('red', Workflows.description))
const {installId, tenantId} = await this.setupFlow(true)
this.log(ux.colorize('cyan', `Now using Tenant ID ${tenantId} and Install ID ${installId}.\n`))
const deployments = await getDeployments(tenantId, installId)
if (deployments.data && deployments.data?.length > 0) {
this.log(printFormattedJSON(deployments.data))
} else {
this.log(ux.colorize('cyan', `No deployment found.\n`))
}
this.log(ux.colorize('red', 'Get Deployments Workflow completed.'))
} catch (error: any) {
if (error.name === 'ExitPromptError') {
this.log(ux.colorize('red', 'Goodbye.'))
} else {
// Handle other errors or rethrow
throw error
}
}
return JSON.stringify('')
}
}