-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for Integration Mappings API (#472)
- Loading branch information
1 parent
9f5efff
commit bbf2548
Showing
12 changed files
with
627 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
'use strict'; | ||
|
||
const BoxCommand = require('../../../box-command'); | ||
const BoxCLIError = require('../../../cli-error'); | ||
const { flags } = require('@oclif/command'); | ||
|
||
class IntegrationMappingsSlackCreateCommand extends BoxCommand { | ||
async run() { | ||
const { flags, args } = this.parse(IntegrationMappingsSlackCreateCommand); | ||
let body = {}; | ||
body.box_item = { | ||
type: 'folder', | ||
id: args.boxItemID | ||
}; | ||
body.partner_item = { | ||
type: 'channel', | ||
id: args.channelID | ||
}; | ||
if (flags['slack-workspace-id']) { | ||
body.partner_item.slack_workspace_id = flags['slack-workspace-id']; | ||
} else if (flags['slack-org-id']) { | ||
body.partner_item.slack_org_id = flags['slack-org-id']; | ||
} else { | ||
throw new BoxCLIError('Either the --slack-workspace-id or --slack-org-id flag must be passed'); | ||
} | ||
if (flags.hasOwnProperty('disable-access-management')) { | ||
body.options = { | ||
is_access_management_disabled: flags['disable-access-management'] | ||
}; | ||
} | ||
|
||
let integrationMapping = await this.client.integrationMappings.createSlackIntegrationMapping(body); | ||
await this.output(integrationMapping); | ||
} | ||
} | ||
|
||
IntegrationMappingsSlackCreateCommand.description = 'Create Slack integration mapping'; | ||
IntegrationMappingsSlackCreateCommand.examples = [ | ||
'box integration-mappings:slack:create 123 AB89X56Y --slack-org-id 789', | ||
'box integration-mappings:slack:create 123 AB89X56Y --slack-workspace-id 999 --disable-access-management' | ||
]; | ||
IntegrationMappingsSlackCreateCommand._endpoint = 'post_integration_mappings_slack'; | ||
|
||
IntegrationMappingsSlackCreateCommand.flags = { | ||
...BoxCommand.flags, | ||
'slack-workspace-id': flags.string({ | ||
description: 'ID of the Slack workspace with which the item would be associated', | ||
exclusive: ['slack-org-id'] | ||
}), | ||
'slack-org-id': flags.string({ | ||
description: 'ID of the Slack organization with which the item would be associated', | ||
exclusive: ['slack-workspace-id'] | ||
}), | ||
'disable-access-management': flags.boolean({ | ||
description: 'Indicates whether or not channel member access to the underlying box item should be automatically managed. ' + | ||
'Depending on type of channel, access is managed through creating collaborations or shared links.', | ||
allowNo: true | ||
}) | ||
}; | ||
|
||
IntegrationMappingsSlackCreateCommand.args = [ | ||
{ | ||
name: 'boxItemID', | ||
required: true, | ||
hidden: false, | ||
description: 'ID of the mapped folder' | ||
}, | ||
{ | ||
name: 'channelID', | ||
required: true, | ||
hidden: false, | ||
description: 'ID of the mapped Slack channel' | ||
} | ||
]; | ||
|
||
module.exports = IntegrationMappingsSlackCreateCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const BoxCommand = require('../../../box-command'); | ||
|
||
class IntegrationMappingsSlackDeleteCommand extends BoxCommand { | ||
async run() { | ||
const { args } = this.parse(IntegrationMappingsSlackDeleteCommand); | ||
|
||
await this.client.integrationMappings.deleteSlackIntegrationMappingById({ integration_mapping_id: args.id }); | ||
this.info(`Deleted Slack integration mapping ${args.id}`); | ||
} | ||
} | ||
|
||
IntegrationMappingsSlackDeleteCommand.description = 'Delete Slack integration mapping'; | ||
IntegrationMappingsSlackDeleteCommand.examples = ['box integration-mappings:slack:delete 123']; | ||
IntegrationMappingsSlackDeleteCommand._endpoint = 'delete_integration_mappings_slack_id'; | ||
|
||
IntegrationMappingsSlackDeleteCommand.flags = { | ||
...BoxCommand.flags | ||
}; | ||
|
||
IntegrationMappingsSlackDeleteCommand.args = [ | ||
{ | ||
name: 'id', | ||
required: true, | ||
hidden: false, | ||
description: 'ID of the integration mapping', | ||
} | ||
]; | ||
|
||
module.exports = IntegrationMappingsSlackDeleteCommand; |
Oops, something went wrong.