Skip to content

Commit

Permalink
Initial release of botservice cli module (Azure#7046)
Browse files Browse the repository at this point in the history
* 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
swagatmishra2007 authored and tjprescott committed Aug 22, 2018
1 parent b1c69f1 commit be58ce8
Show file tree
Hide file tree
Showing 36 changed files with 7,929 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/sphinx/azhelpgen/doc_source_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"batchai": "src/command_modules/azure-cli-batchai/azure/cli/command_modules/batchai/_help.py",
"backup": "src/command_modules/azure-cli-backup/azure/cli/command_modules/backup/_help.py",
"billing": "src/command_modules/azure-cli-billing/azure/cli/command_modules/billing/_help.py",
"botservice": "src/command_modules/azure-cli-botservice/azure/cli/command_modules/botservice/_help.py",
"cdn": "src/command_modules/azure-cli-cdn/azure/cli/command_modules/cdn/_help.py",
"cloud": "src/command_modules/azure-cli-cloud/azure/cli/command_modules/cloud/_help.py",
"consumption": "src/command_modules/azure-cli-consumption/azure/cli/command_modules/consumption/_help.py",
Expand Down
1 change: 0 additions & 1 deletion src/azure-cli-core/azure/cli/core/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,6 @@ def generic_update_command(self, name,
child_collection_prop_name=None, child_collection_key='name', child_arg_name='item_name',
custom_func_name=None, custom_func_type=None, **kwargs):
from azure.cli.core.commands.arm import _cli_generic_update_command

self._check_stale()
merged_kwargs = _merge_kwargs(kwargs, self.group_kwargs, CLI_COMMAND_KWARGS)
# don't inherit deprecation info from command group
Expand Down
8 changes: 8 additions & 0 deletions src/command_modules/azure-cli-botservice/HISTORY.rst
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
3 changes: 3 additions & 0 deletions src/command_modules/azure-cli-botservice/MANIFEST.in
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
7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-botservice/README.rst
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 src/command_modules/azure-cli-botservice/azure/.vscode/tags

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-botservice/azure/__init__.py
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__)
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__)
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__)
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
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
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)
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.
"""
Loading

0 comments on commit be58ce8

Please sign in to comment.