-
Notifications
You must be signed in to change notification settings - Fork 103
/
update.ts
36 lines (30 loc) · 1.25 KB
/
update.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
import { DevicePreference } from '@smartthings/core-sdk'
import { APIOrganizationCommand, inputAndOutputItem } from '@smartthings/cli-lib'
import { chooseDevicePreference, tableFieldDefinitions } from '../../lib/commands/devicepreferences-util'
export default class DevicePreferencesUpdateCommand extends APIOrganizationCommand<typeof DevicePreferencesUpdateCommand.flags> {
static description = 'update a device preference' +
this.apiDocsURL('updatePreferenceById')
static flags = {
...APIOrganizationCommand.flags,
...inputAndOutputItem.flags,
}
static args = [{
name: 'id',
description: 'the device preference id',
}]
static examples = [
{
description: 'select a device preference from a list and update it with data from dp.json',
command: 'smartthings devicepreferences:update -i dp.json',
},
{
description: 'update specified device preference with data from dp.yaml',
command: 'smartthings devicepreferences:update -i dp.yaml motionSensitivity',
},
]
async run(): Promise<void> {
const id = await chooseDevicePreference(this, this.args.id)
await inputAndOutputItem<DevicePreference, DevicePreference>(this, { tableFieldDefinitions },
(_, devicePreference) => this.client.devicePreferences.update(id, devicePreference))
}
}