-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdelete.js
42 lines (33 loc) · 1.38 KB
/
delete.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 { deleteApi } = require('../../requests/api')
const { getIntegrationIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
const BaseCommand = require('../../support/command/base-command')
class DeleteIntegrationCommand extends BaseCommand {
async run() {
const { args } = await this.parse(DeleteIntegrationCommand)
const integrationPath = getIntegrationIdentifierArg(args)
await this.deleteIntegration(integrationPath)
}
async deleteIntegration(integrationPath) {
const [owner, api, version, integrationId] = splitPathParams(integrationPath)
return this.executeHttp({
execute: () => deleteApi([owner, api, version, 'integrations', integrationId]),
onResolve: this.logCommandSuccess({ integrationId, apiPath: [owner, api, version].join('/') }),
options: {}
})
}
}
DeleteIntegrationCommand.description = 'deletes the integration from the given API.'
DeleteIntegrationCommand.examples = [
'swaggerhub integration:delete organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704'
]
DeleteIntegrationCommand.args = {
'OWNER/API_NAME/VERSION/INTEGRATION_ID': Args.string({
required: true,
description: 'Integration to delete for given API on Swaggerhub'
})
}
DeleteIntegrationCommand.flags = {
...BaseCommand.flags
}
module.exports = DeleteIntegrationCommand