-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathupdate.js
More file actions
52 lines (43 loc) · 1.69 KB
/
Copy pathupdate.js
File metadata and controls
52 lines (43 loc) · 1.69 KB
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
43
44
45
46
47
48
49
50
51
52
const { Flags, Args } = require('@oclif/core')
const { putApi } = require('../../requests/api')
const { getIntegrationIdentifierArg, readConfigFile, splitPathParams } = require('../../support/command/parse-input')
const BaseCommand = require('../../support/command/base-command')
class UpdateIntegrationCommand extends BaseCommand {
async run() {
const { args, flags } = await this.parse(UpdateIntegrationCommand)
const integrationPath = getIntegrationIdentifierArg(args)
const config = readConfigFile(flags.file)
await this.updateIntegration(integrationPath, config)
}
async updateIntegration(integrationPath, config) {
const [owner, api, version, integrationId] = splitPathParams(integrationPath)
const updateRequest = {
pathParams: [owner, api, version, 'integrations', integrationId],
body: config
}
return this.executeHttp({
execute: () => putApi(updateRequest),
onResolve: this.logCommandSuccess({ integrationId, apiPath: `${owner}/${api}/${version}` }),
options: {}
})
}
}
UpdateIntegrationCommand.description = 'update the configuration of an API integration.'
UpdateIntegrationCommand.examples = [
'swaggerhub integration:update organization/api/1.0.0/503c2db6-448a-4678-abcd-0123456789abc --file config.json'
]
UpdateIntegrationCommand.args = {
'OWNER/API_NAME/VERSION/INTEGRATION_ID': Args.string({
required: true,
description: 'Integration to update for given API on Swaggerhub'
})
}
UpdateIntegrationCommand.flags = {
file: Flags.string({
char: 'f',
description: 'location of integration configuration file',
required: true
}),
...BaseCommand.flags
}
module.exports = UpdateIntegrationCommand