-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathdelete.ts
50 lines (42 loc) · 1.56 KB
/
delete.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
import { Flags } from '@oclif/core'
import { InstalledSchemaApp } from '@smartthings/core-sdk'
import { APICommand, selectFromList, SelectFromListConfig, WithNamedLocation } from '@smartthings/cli-lib'
import { installedSchemaInstances } from '../../lib/commands/installedschema-util'
export default class InstalledSchemaAppDeleteCommand extends APICommand<typeof InstalledSchemaAppDeleteCommand.flags> {
static description = 'delete an installed schema connector instance' +
this.apiDocsURL('deleteIsaByIsaId')
static flags = {
...APICommand.flags,
location: Flags.string({
char: 'l',
description: 'filter results by location',
multiple: true,
helpValue: '<UUID>',
}),
verbose: Flags.boolean({
description: 'include location name in output',
char: 'v',
}),
}
static args = [{
name: 'id',
description: 'installed schema connector UUID',
}]
async run(): Promise<void> {
const config: SelectFromListConfig<InstalledSchemaApp & WithNamedLocation> = {
primaryKeyName: 'isaId',
sortKeyName: 'appName',
listTableFieldDefinitions: ['appName', 'partnerName', 'partnerSTConnection', 'isaId'],
}
if (this.flags.verbose) {
config.listTableFieldDefinitions.splice(3, 0, 'location')
}
const id = await selectFromList(this, config, {
preselectedId: this.args.id,
listItems: () => installedSchemaInstances(this.client, this.flags.location, this.flags.verbose),
promptMessage: 'Select an installed schema app to delete.',
})
await this.client.schema.deleteInstalledApp(id)
this.log(`Installed schema app ${id} deleted.`)
}
}