-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathexecute.js
42 lines (33 loc) · 1.41 KB
/
execute.js
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
37
38
39
40
41
42
const { Args } = require('@oclif/core')
const { postApi } = require('../../requests/api')
const { getIntegrationIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
const BaseCommand = require('../../support/command/base-command')
class ExecuteIntegrationCommand extends BaseCommand {
async run() {
const { args } = await this.parse(ExecuteIntegrationCommand)
const integrationPath = getIntegrationIdentifierArg(args)
await this.executeIntegration(integrationPath)
}
async executeIntegration(integrationPath) {
const [owner, api, version, integrationId] = splitPathParams(integrationPath)
return this.executeHttp({
execute: () => postApi({ pathParams: [owner, api, version, 'integrations', integrationId, 'execute'] }),
onResolve: this.logCommandSuccess({ integrationId, apiPath: `${owner}/${api}/${version}` }),
options: {}
})
}
}
ExecuteIntegrationCommand.description = 'executes an integration for the given API.'
ExecuteIntegrationCommand.examples = [
'swaggerhub integration:execute organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704'
]
ExecuteIntegrationCommand.args = {
'OWNER/API_NAME/VERSION/INTEGRATION_ID': Args.string({
required: true,
description: 'Integration to execute for given API on Swaggerhub'
})
}
ExecuteIntegrationCommand.flags = {
...BaseCommand.flags
}
module.exports = ExecuteIntegrationCommand