-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathschema.ts
63 lines (55 loc) · 2.05 KB
/
schema.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
58
59
60
61
62
63
import { Flags } from '@oclif/core'
import { SchemaApp } from '@smartthings/core-sdk'
import {
allOrganizationsFlags,
APIOrganizationCommand,
outputItemOrList,
OutputItemOrListConfig,
} from '@smartthings/cli-lib'
import { getSchemaAppEnsuringOrganization } from '../lib/commands/schema-util'
export default class SchemaCommand extends APIOrganizationCommand<typeof SchemaCommand.flags> {
static description = 'list all ST Schema Apps currently available in a user account' +
this.apiDocsURL('getAppsByUserToken', 'getAppsByEndpointAppId')
static flags = {
...APIOrganizationCommand.flags,
...outputItemOrList.flags,
...allOrganizationsFlags,
verbose: Flags.boolean({
description: 'include ARN in output',
char: 'v',
}),
}
static args = [{
name: 'id',
description: 'the schema connector id',
}]
async run(): Promise<void> {
const config: OutputItemOrListConfig<SchemaApp> = {
tableFieldDefinitions: [
'appName', 'partnerName', 'endpointAppId', 'organizationId', 'schemaType', 'hostingType',
// stClientId is missing from the docs
('stClientId' as keyof SchemaApp), 'oAuthAuthorizationUrl', 'oAuthTokenUrl', 'oAuthClientId',
'oAuthClientSecret', 'icon', 'icon2x', 'icon3x',
{ prop: 'lambdaArn', skipEmpty: true },
{ prop: 'lambdaArnAP', skipEmpty: true },
{ prop: 'lambdaArnCN', skipEmpty: true },
{ prop: 'lambdaArnEU', skipEmpty: true },
{ prop: 'webhookUrl', skipEmpty: true },
{ prop: 'userEmail', skipEmpty: true },
],
primaryKeyName: 'endpointAppId',
sortKeyName: 'appName',
listTableFieldDefinitions: ['appName', 'endpointAppId', 'organizationId', 'hostingType'],
}
if (this.flags.verbose) {
config.listTableFieldDefinitions.push({
label: 'ARN/URL',
value: app => app.hostingType === 'lambda' ? app.lambdaArn : app.webhookUrl,
})
}
await outputItemOrList(this, config, this.args.id,
() => this.client.schema.list({ includeAllOrganizations: this.flags['all-organizations'] }),
async id => (await getSchemaAppEnsuringOrganization(this, id, this.flags)).schemaApp,
)
}
}