-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.ts
57 lines (50 loc) · 1.88 KB
/
create.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
import {ux} from '@oclif/core'
import {
commonUniversalBrokerArgs,
commonUniversalBrokerDeploymentId,
commonApiRelatedArgs,
getCommonIds,
commonUniversalBrokerConnectionId,
commonUniversalBrokerIntegrationsIds,
commonUniversalBrokerIntegrationType,
} from '../../common/args.js'
import {printFormattedJSON} from '../../utils/display.js'
import {createIntegrationForConnection} from '../../api/integrations.js'
import {BaseCommand} from '../../base-command.js'
export default class Integrations extends BaseCommand<typeof Integrations> {
static args = {
...commonUniversalBrokerArgs(),
...commonUniversalBrokerConnectionId(true),
...commonUniversalBrokerIntegrationsIds(true),
...commonUniversalBrokerIntegrationType(true),
...commonApiRelatedArgs,
}
static description = 'Universal Broker Connections Integrations - Create operation'
static examples = [
`[with exported TENANT_ID,INSTALL_ID]`,
`<%= config.bin %> <%= command.id %> CONNECTION_ID ORG_ID INTEGRATION_ID`,
`[inline TENANT_ID,INSTALL_ID]`,
`<%= config.bin %> <%= command.id %> TENANT_ID INSTALL_ID CONNECTION_ID ORG_ID INTEGRATION_ID`,
]
async run(): Promise<string> {
this.log('\n' + ux.colorize('red', Integrations.description))
const {args} = await this.parse(Integrations)
const {tenantId} = getCommonIds(args)
const integration = await createIntegrationForConnection(
tenantId,
args.connectionId,
args.type,
args.orgId,
args.integrationId ?? null,
)
const integrationResponse = integration
this.log(
ux.colorize(
'cyan',
`Creating Universal Broker Connections Integration for Connection ${args.connectionId} for Org ${args.orgId}, Integration ${args.integrationId}, Tenant ${tenantId},`,
),
)
this.log(printFormattedJSON(integrationResponse))
return JSON.stringify(integrationResponse)
}
}