/
enrollments.ts
35 lines (26 loc) · 1.09 KB
/
enrollments.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
import { EnrolledChannel } from '@smartthings/core-sdk'
import { outputList, OutputListConfig } from '@smartthings/cli-lib'
import { chooseHub } from '../../../lib/commands/drivers-util'
import { EdgeCommand } from '../../../lib/edge-command'
export default class ChannelsEnrollmentsCommand extends EdgeCommand<typeof ChannelsEnrollmentsCommand.flags> {
static description = 'list all channels a given hub is enrolled in' +
this.apiDocsURL('listDriverChannels')
static flags = {
...EdgeCommand.flags,
...outputList.flags,
}
static args = [{
name: 'idOrIndex',
description: 'the hub id or number in list',
}]
async run(): Promise<void> {
const config: OutputListConfig<EnrolledChannel> = {
primaryKeyName: 'channelId',
sortKeyName: 'name',
listTableFieldDefinitions: ['channelId', 'name', 'description', 'createdDate', 'lastModifiedDate', 'subscriptionUrl'],
}
const hubId = await chooseHub(this, 'Select a hub.', this.args.idOrIndex,
{ allowIndex: true, useConfigDefault: true })
await outputList(this, config, () => this.client.hubdevices.enrolledChannels(hubId))
}
}