forked from Azure/azure-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial release of botservice cli module (Azure#7046)
* initial commit * final changes for cli * fixed flake errors and added license headers * more errors * add botservice to the document source map * missed comma * fixes for flake * addressing comments. * attempt to fix build * fix build * checked build locally. this should succeed! * fix cfg file * fix more errors from build * add manifest file. other fixes * remove azure namespace package from setup.cfg * update manifest to have correct parts to json files. update Bot to bot in docs * added bdist_wheel file * add nspkg * add scope separator. also add package_data to setup.py * add provider scope string * correct sms example help. fix other create docs * disable test check as it throws an exception on ci. enable later * another try * make urlparse python version independent * fixed logic around bot download. amended error message for failed msa app provisioning * fix indendation * more documentation fixes as per comments
- Loading branch information
1 parent
b1c69f1
commit be58ce8
Showing
36 changed files
with
7,929 additions
and
1 deletion.
There are no files selected for viewing
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
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,8 @@ | ||
.. :changelog: | ||
Release History | ||
=============== | ||
|
||
0.1.0 | ||
+++++ | ||
* Initial Bot Service CLI Release |
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,3 @@ | ||
include *.rst | ||
include azure\cli\command_modules\botservice\functionapp.template.json | ||
include azure\cli\command_modules\botservice\webapp.template.json |
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,7 @@ | ||
Microsoft Azure CLI 'bot service' Command Module | ||
======================================================= | ||
|
||
This package is for the 'bot service' module. | ||
i.e. 'az botservice' | ||
|
||
|
625 changes: 625 additions & 0 deletions
625
src/command_modules/azure-cli-botservice/azure/.vscode/tags
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import pkg_resources | ||
pkg_resources.declare_namespace(__name__) |
7 changes: 7 additions & 0 deletions
7
src/command_modules/azure-cli-botservice/azure/cli/__init__.py
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,7 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import pkg_resources | ||
pkg_resources.declare_namespace(__name__) |
7 changes: 7 additions & 0 deletions
7
src/command_modules/azure-cli-botservice/azure/cli/command_modules/__init__.py
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,7 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import pkg_resources | ||
pkg_resources.declare_namespace(__name__) |
38 changes: 38 additions & 0 deletions
38
src/command_modules/azure-cli-botservice/azure/cli/command_modules/botservice/__init__.py
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,38 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure.cli.core import AzCommandsLoader, ModExtensionSuppress | ||
from azure.cli.command_modules.botservice._help import helps # pylint: disable=unused-import | ||
from azure.cli.command_modules.botservice._client_factory import get_botservice_management_client | ||
|
||
|
||
class BotServiceCommandsLoader(AzCommandsLoader): | ||
|
||
def __init__(self, cli_ctx=None): | ||
from azure.cli.core.commands import CliCommandType | ||
custom_type = CliCommandType( | ||
operations_tmpl='azure.cli.command_modules.botservice.custom#{}', | ||
client_factory=get_botservice_management_client) | ||
super(BotServiceCommandsLoader, self).__init__(cli_ctx=cli_ctx, | ||
custom_command_type=custom_type, | ||
min_profile='2017-03-10-profile', | ||
suppress_extension=ModExtensionSuppress( | ||
__name__, | ||
'botservice', | ||
'0.3.0', | ||
reason='These commands are now in the CLI', | ||
recommend_remove=True)) | ||
|
||
def load_command_table(self, args): | ||
from azure.cli.command_modules.botservice.commands import load_command_table | ||
load_command_table(self, args) | ||
return self.command_table | ||
|
||
def load_arguments(self, command): | ||
from azure.cli.command_modules.botservice._params import load_arguments | ||
load_arguments(self, command) | ||
|
||
|
||
COMMAND_LOADER_CLS = BotServiceCommandsLoader |
26 changes: 26 additions & 0 deletions
26
...mand_modules/azure-cli-botservice/azure/cli/command_modules/botservice/_client_factory.py
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,26 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
def get_botservice_management_client(cli_ctx, *_): | ||
from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
from azure.mgmt.botservice import AzureBotService | ||
return get_mgmt_service_client(cli_ctx, AzureBotService) | ||
|
||
|
||
def get_botOperations_client(cli_ctx, *_): | ||
return get_botservice_management_client(cli_ctx).bots | ||
|
||
|
||
def get_botChannels_client(cli_ctx, *_): | ||
return get_botservice_management_client(cli_ctx).channels | ||
|
||
|
||
def get_operations_client(cli_ctx, *_): | ||
return get_botservice_management_client(cli_ctx).operations | ||
|
||
|
||
def get_botConnections_client(cli_ctx, *_): | ||
return get_botservice_management_client(cli_ctx).bot_connection |
30 changes: 30 additions & 0 deletions
30
...d_modules/azure-cli-botservice/azure/cli/command_modules/botservice/_exception_handler.py
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,30 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from knack.util import CLIError | ||
|
||
|
||
def bot_exception_handler(ex): | ||
from azure.mgmt.botservice.models import ErrorException | ||
from msrestazure.azure_exceptions import CloudError | ||
from msrest.exceptions import ClientRequestError # pylint: disable=import-error | ||
if isinstance(ex, ErrorException): | ||
message = 'an error occurred with code:{0} and message:{1}'.format( | ||
ex.error.error.code, | ||
ex.error.error.message | ||
) | ||
raise CLIError(message) | ||
elif isinstance(ex, CloudError) and ex.status_code == 404: | ||
return None | ||
elif isinstance(ex, ClientRequestError): | ||
message = 'Error occurred in sending request. Please file an issue on {0}'.format( | ||
'https://github.com/Microsoft/botbuilder-tools/issues' | ||
) | ||
raise CLIError(message) | ||
else: | ||
message = 'Unknown error during execution. Please file an issue on {0}'.format( | ||
'https://github.com/Microsoft/botbuilder-tools/issues' | ||
) | ||
raise CLIError(message) |
206 changes: 206 additions & 0 deletions
206
src/command_modules/azure-cli-botservice/azure/cli/command_modules/botservice/_help.py
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,206 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from knack.help_files import helps | ||
|
||
helps['bot'] = """ | ||
type: group | ||
short-summary: Manage Microsoft Bot Services. | ||
""" | ||
helps['bot create'] = """ | ||
type: command | ||
short-summary: Create a new bot. | ||
""" | ||
helps['bot show'] = """ | ||
type: command | ||
short-summary: Get an existing bot. | ||
""" | ||
helps['bot prepare-publish'] = """ | ||
type: command | ||
short-summary: Add scripts to your local source code directory to | ||
be able to publish back using `az bot publish`. | ||
""" | ||
helps['bot delete'] = """ | ||
type: command | ||
short-summary: Delete an existing bot. | ||
""" | ||
helps['bot update'] = """ | ||
type: command | ||
short-summary: Update an existing bot. | ||
examples: | ||
- name: Update description on a bot | ||
text: |- | ||
az bot update -n botName -g MyResourceGroup --set properties.description="some description" | ||
""" | ||
helps['bot publish'] = """ | ||
type: command | ||
short-summary: Publish to a bot's associated app service. | ||
long-summary: Publish your source code to your bot's associated app service. | ||
examples: | ||
- name: Publish source code to your Azure App, from within the bot code folder | ||
text: |- | ||
az bot publish -n botName -g MyResourceGroup | ||
""" | ||
helps['bot download'] = """ | ||
type: command | ||
short-summary: Download an existing bot. | ||
long-summary: The source code is downloaded from the web app associated with the bot. | ||
You can then make changes to it and publish it back to your app. | ||
""" | ||
helps['bot facebook create'] = """ | ||
type: command | ||
short-summary: Create the Facebook Channel on a bot. | ||
examples: | ||
- name: Create the Facebook Channel for a bot | ||
text: |- | ||
az bot facebook create -n botName -g MyResourceGroup -appid myAppId | ||
--page-d myPageId --secret mySecret --token myToken | ||
""" | ||
helps['bot email create'] = """ | ||
type: command | ||
short-summary: Create the Email Channel on a bot. | ||
examples: | ||
- name: Create the Email Channel for a bot | ||
text: |- | ||
az bot email create -n botName -g MyResourceGroup -a abc@outlook.com | ||
-p password | ||
""" | ||
helps['bot msteams create'] = """ | ||
type: command | ||
short-summary: Create the Microsoft Teams Channel on a bot. | ||
examples: | ||
- name: Create the Microsoft Teams Channel for a bot with calling enabled | ||
text: |- | ||
az bot msteams create -n botName -g MyResourceGroup --enable-calling | ||
--calling-web-hook https://www.myapp.com/ | ||
""" | ||
helps['bot skype create'] = """ | ||
type: command | ||
short-summary: Create the Skype Channel on a bot. | ||
examples: | ||
- name: Create the Skype Channel for a bot with messaging and screen sharing enabled | ||
text: |- | ||
az bot skype create -n botName -g MyResourceGroup --enable-messaging | ||
--enable-screen-sharing | ||
""" | ||
helps['bot kik create'] = """ | ||
type: command | ||
short-summary: Create the Kik Channel on a bot. | ||
examples: | ||
- name: Create the Kik Channel for a bot. | ||
text: |- | ||
az bot kik create -n botName -g MyResourceGroup -u mykikname | ||
-p password --key key --is-validated | ||
""" | ||
helps['bot directline create'] = """ | ||
type: command | ||
short-summary: Create the DirectLine Channel on a bot with only v3 protocol enabled. | ||
examples: | ||
- name: Create the DirectLine Channel for a bot. | ||
text: |- | ||
az bot directline create -n botName -g MyResourceGroup --disablev1 | ||
""" | ||
helps['bot telegram create'] = """ | ||
type: command | ||
short-summary: Create the Telegram Channel on a bot. | ||
examples: | ||
- name: Create the Telegram Channel for a bot. | ||
text: |- | ||
az bot telegram create -n botName -g MyResourceGroup --access-token token | ||
--is-validated | ||
""" | ||
helps['bot sms create'] = """ | ||
type: command | ||
short-summary: Create the SMS Channel on a bot. | ||
examples: | ||
- name: Create the SMS Channel for a bot. | ||
text: |- | ||
az bot sms create -n botName -g MyResourceGroup --account-sid sid | ||
--auth-token token --is-validated | ||
""" | ||
helps['bot slack create'] = """ | ||
type: command | ||
short-summary: Create the Slack Channel on a bot. | ||
examples: | ||
- name: Create the Slack Channel for a bot. | ||
text: |- | ||
az bot slack create -n botName -g MyResourceGroup --client-id clientid | ||
--client-secret secret --verification-token token | ||
""" | ||
helps['bot authsetting'] = """ | ||
type: group | ||
short-summary: Manage OAuth connection settings on a bot. | ||
""" | ||
helps['bot authsetting create'] = """ | ||
type: command | ||
short-summary: Create an OAuth connection setting on a bot. | ||
examples: | ||
- name: Create a new OAuth connection setting on a bot. | ||
text: |- | ||
az bot authsetting create -g MyResourceGroup -n botName -c myConnectionName | ||
--client-id clientId --client-secret secret --scopes "scope1 scope2" --service google | ||
--parameters id=myid | ||
""" | ||
helps['bot authsetting show'] = """ | ||
type: command | ||
short-summary: Show details of an OAuth connection setting on a bot. | ||
""" | ||
helps['bot authsetting list'] = """ | ||
type: command | ||
short-summary: Show all OAuth connection settings on a bot. | ||
""" | ||
helps['bot authsetting delete'] = """ | ||
type: command | ||
short-summary: Delete an OAuth connection setting on a bot. | ||
""" | ||
helps['bot authsetting list-providers'] = """ | ||
type: command | ||
short-summary: List details for all service providers available for creating OAuth connection settings. | ||
examples: | ||
- name: List all service providers. | ||
text: |- | ||
az bot authsetting list-providers | ||
- name: Filter by a particular type of service provider. | ||
text: |- | ||
az bot authsetting list-providers --provider-name google | ||
""" | ||
|
||
|
||
for channel in ['Facebook', 'email', 'Skype', 'Kik', 'Directline', 'Telegram', 'SMS', 'Slack']: | ||
channel_name = channel.lower() | ||
helps['bot {0} delete'.format(channel_name)] = """ | ||
type: command | ||
short-summary: Delete the {0} Channel on a bot | ||
""".format(channel) | ||
helps['bot {0} show'.format(channel_name)] = """ | ||
type: command | ||
short-summary: Get details of the {0} Channel on a bot | ||
""".format(channel) | ||
helps['bot {0}'.format(channel_name)] = """ | ||
type: group | ||
short-summary: Manage the {0} Channel on a bot. | ||
""".format(channel) | ||
|
||
|
||
helps['bot msteams delete'] = """ | ||
type: command | ||
short-summary: Delete the Microsoft Teams Channel on a bot | ||
""" | ||
helps['bot msteams show'] = """ | ||
type: command | ||
short-summary: Get details of the Microsoft Teams Channel on a bot | ||
""" | ||
helps['bot msteams'] = """ | ||
type: group | ||
short-summary: Manage the Microsoft Teams Channel on a bot. | ||
""" | ||
helps['bot webchat show'] = """ | ||
type: command | ||
short-summary: Get details of the Webchat Channel on a bot | ||
""" | ||
helps['bot webchat'] = """ | ||
type: group | ||
short-summary: Manage the Webchat Channel on a bot. | ||
""" |
Oops, something went wrong.