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

Function handler

src/commands/schema/create.ts:57–94  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

55 .epilog(buildEpilog({ command, apiDocs: 'postApps' }))
56
57const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
58 const command = await apiOrganizationCommand(argv)
59
60 const createApp = async (
61 _: void,
62 request: SchemaAppWithOrganization,
63 ): Promise<SchemaCreateResponse> => {
64 const { organizationId, ...data } = request
65 if (argv.authorize) {
66 if (data.hostingType === 'lambda') {
67 const principal = argv.principal ?? schemaAWSPrincipal
68 const statementId = argv.statement
69
70 if (data.lambdaArn) {
71 await addSchemaPermission(data.lambdaArn, principal, statementId)
72 }
73 if (data.lambdaArnAP) {
74 await addSchemaPermission(data.lambdaArnAP, principal, statementId)
75 }
76 if (data.lambdaArnCN) {
77 await addSchemaPermission(data.lambdaArnCN, principal, statementId)
78 }
79 if (data.lambdaArnEU) {
80 await addSchemaPermission(data.lambdaArnEU, principal, statementId)
81 }
82 } else {
83 fatalError('Authorization is not applicable to WebHook schema connectors')
84 }
85 }
86 return command.client.schema.create(data, organizationId)
87 }
88 await inputAndOutputItem(
89 command,
90 { tableFieldDefinitions: ['endpointAppId', 'stClientId', 'stClientSecret'] },
91 createApp,
92 userInputProcessor(() => getSchemaAppCreateFromUser(command, argv.dryRun ?? false)),
93 )
94}
95
96const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
97export default cmd

Callers

nothing calls this directly

Calls 4

apiOrganizationCommandFunction · 0.85
inputAndOutputItemFunction · 0.85
userInputProcessorFunction · 0.85

Tested by

no test coverage detected