MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / handler

Function handler

src/commands/deviceprofiles/create.ts:51–71  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

49 }))
50
51const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
52 const command = await apiOrganizationCommand(argv)
53
54 const createDeviceProfile = async (_: void, data: DeviceDefinitionRequest): Promise<DeviceProfile> => {
55 if (data.view) {
56 throw new Error('Input contains "view" property. Use deviceprofiles:view:create instead.')
57 }
58
59 if (!data.metadata?.vid) {
60 const profileAndConfig = await createWithDefaultConfig(command.client, data)
61 return profileAndConfig.deviceProfile
62 }
63
64 return await command.client.deviceProfiles.create(cleanupForCreate(data))
65 }
66 await inputAndOutputItem(
67 command,
68 { buildTableOutput: data => buildTableOutput(command.tableGenerator, data) },
69 createDeviceProfile, userInputProcessor(() => getInputFromUser(command)),
70 )
71}
72
73const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
74export default cmd

Callers

nothing calls this directly

Calls 5

apiOrganizationCommandFunction · 0.85
inputAndOutputItemFunction · 0.85
userInputProcessorFunction · 0.85
buildTableOutputFunction · 0.50
getInputFromUserFunction · 0.50

Tested by

no test coverage detected