-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathupdate.ts
32 lines (27 loc) · 1.01 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
import { Flags } from '@oclif/core'
import { Room, RoomRequest } from '@smartthings/core-sdk'
import { APICommand, CommonOutputProducer, inputAndOutputItem } from '@smartthings/cli-lib'
import { chooseRoom, tableFieldDefinitions } from '../../../lib/commands/locations/rooms-util'
export default class RoomsUpdateCommand extends APICommand<typeof RoomsUpdateCommand.flags> {
static description = 'update a room' +
this.apiDocsURL('updateRoom')
static flags = {
...APICommand.flags,
...inputAndOutputItem.flags,
location: Flags.string({
char: 'l',
description: 'a specific location to query',
helpValue: '<UUID>',
}),
}
static args = [{
name: 'id',
description: 'room UUID',
}]
async run(): Promise<void> {
const [roomId, locationId] = await chooseRoom(this, this.flags.location, this.args.id)
const config: CommonOutputProducer<Room> = { tableFieldDefinitions }
await inputAndOutputItem<RoomRequest, Room>(this, config,
(_, data) => this.client.rooms.update(roomId, data, locationId))
}
}