diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b742ba517db..4c2a488e6e1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -24,4 +24,6 @@ /src/eventgrid/ @kalyanaj +/src/botservice/ @swagatmishra2007 + /src/storage-preview/ @williexu diff --git a/src/botservice/HISTORY.rst b/src/botservice/HISTORY.rst new file mode 100644 index 00000000000..f1c931d101b --- /dev/null +++ b/src/botservice/HISTORY.rst @@ -0,0 +1,6 @@ +Release History +=============== + +0.1.0 (2018-02-16) +------------------ +* inital bot service CLI \ No newline at end of file diff --git a/src/botservice/MANIFEST.in b/src/botservice/MANIFEST.in new file mode 100644 index 00000000000..677a2e74656 --- /dev/null +++ b/src/botservice/MANIFEST.in @@ -0,0 +1,2 @@ +include azext_bot\functionapp.template.json +include azext_bot\webapp.template.json diff --git a/src/botservice/README.rst b/src/botservice/README.rst new file mode 100644 index 00000000000..4bebf4bd39a --- /dev/null +++ b/src/botservice/README.rst @@ -0,0 +1,7 @@ +Microsoft Azure CLI 'bot service' Command Module +======================================================= + +This package is for the 'bot service' module. +i.e. 'az botservice' + + diff --git a/src/botservice/azext_bot/__init__.py b/src/botservice/azext_bot/__init__.py new file mode 100644 index 00000000000..2d89efd5ded --- /dev/null +++ b/src/botservice/azext_bot/__init__.py @@ -0,0 +1,32 @@ +# -------------------------------------------------------------------------------------------- +# 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 +from azext_bot._help import helps # pylint: disable=unused-import +from azext_bot._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='azext_bot.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') + + def load_command_table(self, args): + from azext_bot.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_bot._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = BotServiceCommandsLoader diff --git a/src/botservice/azext_bot/_client_factory.py b/src/botservice/azext_bot/_client_factory.py new file mode 100644 index 00000000000..fdb4dba7dcc --- /dev/null +++ b/src/botservice/azext_bot/_client_factory.py @@ -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 azext_bot.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_botServices_client(cli_ctx, *_): + return get_botservice_management_client(cli_ctx).bot_services + + +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 diff --git a/src/botservice/azext_bot/_exception_handler.py b/src/botservice/azext_bot/_exception_handler.py new file mode 100644 index 00000000000..eb31b7cf13a --- /dev/null +++ b/src/botservice/azext_bot/_exception_handler.py @@ -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 azext_bot.botservice.models import ErrorException + from msrestazure.azure_exceptions import CloudError + from msrest.exceptions import ClientRequestError + 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) diff --git a/src/botservice/azext_bot/_help.py b/src/botservice/azext_bot/_help.py new file mode 100644 index 00000000000..b39685f5338 --- /dev/null +++ b/src/botservice/azext_bot/_help.py @@ -0,0 +1,136 @@ +# -------------------------------------------------------------------------------------------- +# 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 Bot Services. +""" +helps['bot create'] = """ + type: command + short-summary: Create a new Bot Service. +""" +helps['bot show'] = """ + type: command + short-summary: get an existing Bot Service. +""" +helps['bot delete'] = """ + type: command + short-summary: delete an existing Bot Service. +""" +helps['bot update'] = """ + type: command + short-summary: update an existing Bot Service. + 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 an existing Bot Service. + long-summary: publish your github or zip code to a bot service. + This lets you overwrite the existing template code on a bot. +""" +helps['bot download'] = """ + type: command + short-summary: download an existing Bot Service. + long-summary: download the code deployed to your web/function app for your bot. + You can then make changes to it and publish it back to your app. +""" +helps['bot facebook create'] = """ + type: command + short-summary: Create Facebook Channel on a Bot. +""" +helps['bot email create'] = """ + type: command + short-summary: Create Email Channel on a Bot. + examples: + - name: Add Email Channel for a Bot + text: |- + az bot email create -n botName -g MyResourceGroup -a abc@outlook.com + -p password --enable +""" +helps['bot msteams create'] = """ + type: command + short-summary: Create MsTeams Channel on a Bot. + examples: + - name: Add MsTeams Channel for a Bot with messaging and video enabled + text: |- + az bot msteams -n botName -g MyResourceGroup --enable-messaging + --enable-video --enable +""" +helps['bot skype create'] = """ + type: command + short-summary: Create Skype Channel on a Bot. + examples: + - name: Add Skype Channel for a Bot with messaging and screen sharing enabled + text: |- + az bot skype -n botName -g MyResourceGroup --enable-messaging + --enable-screen-sharing --enable +""" +helps['bot kik create'] = """ + type: command + short-summary: Create Kik Channel on a Bot. + examples: + - name: Add Kik Channel for a Bot. + text: |- + az bot kik create -n botName -g MyResourceGroup -u mykikname + -p password --key key --is-validated --enable +""" +helps['bot webchat create'] = """ + type: command + short-summary: Create WebChat Channel on a Bot. + examples: + - name: Add WebChat Channel for a Bot. + text: |- + az bot webchat create -n botName -g MyResourceGroup --enablev3 --enable +""" +helps['bot directline create'] = """ + type: command + short-summary: Create DirectLine Channel on a Bot. + examples: + - name: Add DirectLine Channel for a Bot. + text: |- + az bot webchat create -n botName -g MyResourceGroup --enablev3 --enable +""" +helps['bot telegram create'] = """ + type: command + short-summary: Create Telegram Channel on a Bot. + examples: + - name: Add Telegram Channel for a Bot. + text: |- + az bot telegram create -n botName -g MyResourceGroup --access-token token + --is-validated --enable +""" +helps['bot sms create'] = """ + type: command + short-summary: Create Sms Channel on a Bot. + examples: + - name: Add Sms Channel for a Bot. + text: |- + az bot sms create -n botName -g MyResourceGroup --account-sid sid + --auth-token token --is-validated --enable +""" +helps['bot slack create'] = """ + type: command + short-summary: Create Slack Channel on a Bot. +""" + +for channel in ['facebook', 'email', 'msteams', 'skype', 'kik', 'webchat', 'directline', 'telegram', 'sms', 'slack']: + channelTitle = channel[:1].upper() + channel[1:] + helps['bot {0} delete'.format(channel)] = """ + type: command + short-summary: Delete {0} Channel on a Bot + """.format(channelTitle) + helps['bot {0} get'.format(channel)] = """ + type: command + short-summary: Get details of {0} Channel on a Bot + """.format(channelTitle) + helps['bot {0}'.format(channel)] = """ + type: group + short-summary: Manage {0} Channel on a Bot. + """.format(channelTitle) diff --git a/src/botservice/azext_bot/_params.py b/src/botservice/azext_bot/_params.py new file mode 100644 index 00000000000..d3518726bbd --- /dev/null +++ b/src/botservice/azext_bot/_params.py @@ -0,0 +1,111 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from knack.arguments import CLIArgumentType + +from azure.cli.core.commands.parameters import ( + tags_type, + resource_group_name_type, + get_resource_name_completion_list, + get_enum_type, + get_three_state_flag) + +name_arg_type = CLIArgumentType(metavar='NAME', configured_default='botname') + + +def load_arguments(self, _): + with self.argument_context('bot') as c: + c.argument('resource_group_name', arg_type=resource_group_name_type) + c.argument('resource_name', options_list=['--name', '-n'], help='the Resource Name of the bot.', arg_type=name_arg_type) + + with self.argument_context('bot create') as c: + c.argument('sku_name', options_list=['--sku'], arg_type=get_enum_type(['F0', 'S1']), help='the Sku of the Bot', arg_group='Registration Bot Specific') + c.argument('kind', options_list=['--kind', '-k'], arg_type=get_enum_type(['registration', 'function', 'webapp']), help='The Kind of the Bot.') + c.argument('display_name', help='the Display Name of the bot.If not specified, defaults to the name of the bot.', arg_group='Registration Bot Specific') + c.argument('description', options_list=['--description', '-d'], help='the Description of the bot.', arg_group='Registration Bot Specific') + c.argument('endpoint', options_list=['-e', '--endpoint'], help='the Messaging Endpoint of the bot.', arg_group='Registration Bot Specific') + c.argument('msa_app_id', options_list=['--appid'], help='the msa account id to be used with the bot.') + c.argument('password', options_list=['-p', '--password'], help='the msa password for the bot from developer portal.') + c.argument('storageAccountName', options_list=['-s', '--storage'], help='Storage Account Name to be used with the bot.If one is not provided, a new account will be created.', arg_group='Web/Function Bot Specific') + c.argument('tags', help='set of tags to add to the bot.') + c.argument('bot_json', options_list=['--msbot'], help='show the output as json compatible with a .bot file', arg_type=get_three_state_flag()) + c.argument('language', help='The language to be used to create the bot.', options_list=['--lang'], arg_type=get_enum_type(['Csharp', 'Node']), arg_group='Web/Function Bot Specific') + c.argument('appInsightsLocation', help='The location for the app insights to be used with the bot.', options_list=['--insights'], arg_group='Web/Function Bot Specific') + + with self.argument_context('bot publish') as c: + c.argument('code_dir', options_list=['--code-dir'], help='The root directory to which the code will be downloaded.') + c.argument('git_url', options_list=['--git-url'], help='Url to the git repo containing the code to be published.') + c.argument('branch', options_list=['--branch'], help='Git branch from which code will be published.') + + with self.argument_context('bot download') as c: + c.argument('file_save_path', options_list=['--save-path'], help='the root directory to which the file should be saved to.') + + with self.argument_context('bot show') as c: + c.argument('bot_json', options_list=['--msbot'], help='show the output as json compatible with a .bot file', arg_type=get_three_state_flag()) + + with self.argument_context('bot facebook create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='add the channel in a disabled state') + c.argument('page_id', options_list=['--page-id'], help='page id of the facebook page to be used for the bot.') + c.argument('app_id', options_list=['--appid'], help='the facebook application id.') + c.argument('app_secret', options_list=['--secret'], help='the facebook application secret.') + c.argument('access_token', options_list=['--token'], help='the facebook application access token.') + + with self.argument_context('bot email create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag()) + c.argument('email_address', options_list=['--email-address', '-a'], help='the email address for the bot.') + c.argument('password', options_list=['--password', '-p'], help='the email password for the bot.') + + with self.argument_context('bot msteams create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='add the channel in a disabled state') + c.argument('enable_messaging', help='Enable messaging on Skype', arg_type=get_three_state_flag()) + c.argument('enable_media_cards', help='Enable media cards on Skype', arg_type=get_three_state_flag()) + c.argument('enable_video', help='Enable video on Skype', arg_type=get_three_state_flag()) + c.argument('enable_calling', help='Enable calling on Skype', arg_type=get_three_state_flag()) + + with self.argument_context('bot skype create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='add the channel in a disabled state') + c.argument('enable_messaging', help='Enable messaging on Skype', arg_type=get_three_state_flag()) + c.argument('enable_media_cards', help='Enable media cards on Skype', arg_type=get_three_state_flag()) + c.argument('enable_video', help='Enable video on Skype', arg_type=get_three_state_flag()) + c.argument('enable_calling', help='Enable calling on Skype', arg_type=get_three_state_flag()) + c.argument('enable_screen_sharing', help='Enable screen sharing on Skype', arg_type=get_three_state_flag()) + c.argument('enable_groups', help='Enable groups on Skype', arg_type=get_three_state_flag()) + c.argument('calling_web_hook', help='The calling web hook to use on Skype') + + with self.argument_context('bot kik create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='add the channel in a disabled state') + c.argument('user_name', options_list=['--user-name', '-u'], help='kik user name') + c.argument('is_validated', help='Has the user name been validated', arg_type=get_three_state_flag()) + c.argument('api_key', options_list=['--key'], help='the api key for the kik account') + + with self.argument_context('bot webchat create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='add the channel in a disabled state') + c.argument('site_name', options_list=['-s', '--site-name'], help='name of the webchat channel site') + c.argument('enable_preview', help='Enable preview features on the chat control', arg_type=get_three_state_flag()) + + with self.argument_context('bot directline create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='add the channel in a disabled state') + c.argument('site_name', options_list=['-s', '--site-name'], help='name of the webchat channel site') + c.argument('is_v1_disabled', options_list=['--disablev1'], help='Enable v1 channel protocol', arg_type=get_three_state_flag()) + c.argument('is_v3_disabled', options_list=['--disablev3'], help='Enable v3 channel protocol', arg_type=get_three_state_flag()) + + with self.argument_context('bot telegram create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag()) + c.argument('access_token', help='The access token for the telegram account') + c.argument('is_validated', help='Has the user name been validated', arg_type=get_three_state_flag()) + + with self.argument_context('bot sms create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='add the channel in a disabled state') + c.argument('account_sid', help='The account sid for the twilio account') + c.argument('auth_token', help='The token token for the twilio account.') + c.argument('is_validated', help='Has the user name been validated.', arg_type=get_three_state_flag()) + c.argument('phone', help='the phone number for the twilio account.') + + with self.argument_context('bot slack create') as c: + c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='add the channel in a disabled state') + c.argument('client_secret', help='The client secret from slack') + c.argument('client_id', help='The client id from slack') + c.argument('verification_token', help='The verification token from slack') + c.argument('landing_page_url', help='The landing page url to redirect to after login') diff --git a/src/botservice/azext_bot/azext_metadata.json b/src/botservice/azext_bot/azext_metadata.json new file mode 100644 index 00000000000..85be557b589 --- /dev/null +++ b/src/botservice/azext_bot/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.minCliCoreVersion": "2.0.30", + "azext.isPreview": true +} \ No newline at end of file diff --git a/src/botservice/azext_bot/botservice/__init__.py b/src/botservice/azext_bot/botservice/__init__.py new file mode 100644 index 00000000000..2d20da87551 --- /dev/null +++ b/src/botservice/azext_bot/botservice/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .azure_bot_service import AzureBotService +from .version import VERSION + +__all__ = ['AzureBotService'] + +__version__ = VERSION diff --git a/src/botservice/azext_bot/botservice/azure_bot_service.py b/src/botservice/azext_bot/botservice/azure_bot_service.py new file mode 100644 index 00000000000..3b955a8470e --- /dev/null +++ b/src/botservice/azext_bot/botservice/azure_bot_service.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import ServiceClient +from msrest import Serializer, Deserializer +from msrestazure import AzureConfiguration +from .version import VERSION +from .operations.bots_operations import BotsOperations +from .operations.channels_operations import ChannelsOperations +from .operations.operations import Operations +from . import models + + +class AzureBotServiceConfiguration(AzureConfiguration): + """Configuration for AzureBotService + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Azure Subscription ID. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(AzureBotServiceConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-mgmt-botservice/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id + + +class AzureBotService(object): + """Azure Bot Service is a platform for creating smart conversational agents. + + :ivar config: Configuration for client. + :vartype config: AzureBotServiceConfiguration + + :ivar bots: Bots operations + :vartype bots: azure.mgmt.botservice.operations.BotsOperations + :ivar channels: Channels operations + :vartype channels: azure.mgmt.botservice.operations.ChannelsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.botservice.operations.Operations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Azure Subscription ID. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = AzureBotServiceConfiguration(credentials, subscription_id, base_url) + self._client = ServiceClient(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2017-12-01' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.bots = BotsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.channels = ChannelsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/src/botservice/azext_bot/botservice/models/__init__.py b/src/botservice/azext_bot/botservice/models/__init__.py new file mode 100644 index 00000000000..52017029217 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/__init__.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .sku import Sku +from .resource import Resource +from .bot_properties import BotProperties +from .bot import Bot +from .channel import Channel +from .bot_channel import BotChannel +from .facebook_page import FacebookPage +from .facebook_channel_properties import FacebookChannelProperties +from .facebook_channel import FacebookChannel +from .email_channel_properties import EmailChannelProperties +from .email_channel import EmailChannel +from .ms_teams_channel_properties import MsTeamsChannelProperties +from .ms_teams_channel import MsTeamsChannel +from .skype_channel_properties import SkypeChannelProperties +from .skype_channel import SkypeChannel +from .kik_channel_properties import KikChannelProperties +from .kik_channel import KikChannel +from .web_chat_site import WebChatSite +from .web_chat_channel_properties import WebChatChannelProperties +from .web_chat_channel import WebChatChannel +from .direct_line_site import DirectLineSite +from .direct_line_channel_properties import DirectLineChannelProperties +from .direct_line_channel import DirectLineChannel +from .telegram_channel_properties import TelegramChannelProperties +from .telegram_channel import TelegramChannel +from .sms_channel_properties import SmsChannelProperties +from .sms_channel import SmsChannel +from .slack_channel_properties import SlackChannelProperties +from .slack_channel import SlackChannel +from .error_body import ErrorBody +from .error import Error, ErrorException +from .operation_display_info import OperationDisplayInfo +from .operation_entity import OperationEntity +from .check_name_availability_request_body import CheckNameAvailabilityRequestBody +from .check_name_availability_response_body import CheckNameAvailabilityResponseBody +from .bot_paged import BotPaged +from .bot_channel_paged import BotChannelPaged +from .operation_entity_paged import OperationEntityPaged +from .azure_bot_service_enums import ( + SkuName, + SkuTier, + Kind, + ChannelName, +) + +__all__ = [ + 'Sku', + 'Resource', + 'BotProperties', + 'Bot', + 'Channel', + 'BotChannel', + 'FacebookPage', + 'FacebookChannelProperties', + 'FacebookChannel', + 'EmailChannelProperties', + 'EmailChannel', + 'MsTeamsChannelProperties', + 'MsTeamsChannel', + 'SkypeChannelProperties', + 'SkypeChannel', + 'KikChannelProperties', + 'KikChannel', + 'WebChatSite', + 'WebChatChannelProperties', + 'WebChatChannel', + 'DirectLineSite', + 'DirectLineChannelProperties', + 'DirectLineChannel', + 'TelegramChannelProperties', + 'TelegramChannel', + 'SmsChannelProperties', + 'SmsChannel', + 'SlackChannelProperties', + 'SlackChannel', + 'ErrorBody', + 'Error', 'ErrorException', + 'OperationDisplayInfo', + 'OperationEntity', + 'CheckNameAvailabilityRequestBody', + 'CheckNameAvailabilityResponseBody', + 'BotPaged', + 'BotChannelPaged', + 'OperationEntityPaged', + 'SkuName', + 'SkuTier', + 'Kind', + 'ChannelName', +] diff --git a/src/botservice/azext_bot/botservice/models/azure_bot_service_enums.py b/src/botservice/azext_bot/botservice/models/azure_bot_service_enums.py new file mode 100644 index 00000000000..805757bdd0e --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/azure_bot_service_enums.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class SkuName(Enum): + + f0 = "F0" + s1 = "S1" + + +class SkuTier(Enum): + + free = "Free" + standard = "Standard" + + +class Kind(Enum): + + sdk = "sdk" + designer = "designer" + bot = "bot" + function = "function" + + +class ChannelName(Enum): + + facebook_channel = "FacebookChannel" + email_channel = "EmailChannel" + kik_channel = "KikChannel" + telegram_channel = "TelegramChannel" + slack_channel = "SlackChannel" + ms_teams_channel = "MsTeamsChannel" + skype_channel = "SkypeChannel" + web_chat_channel = "WebChatChannel" + direct_line_channel = "DirectLineChannel" + sms_channel = "SmsChannel" diff --git a/src/botservice/azext_bot/botservice/models/bot.py b/src/botservice/azext_bot/botservice/models/bot.py new file mode 100644 index 00000000000..ec00bdc1581 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/bot.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class Bot(Resource): + """Bot resource definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Specifies the resource ID. + :vartype id: str + :ivar name: Specifies the name of the resource. + :vartype name: str + :param location: Specifies the location of the resource. + :type location: str + :ivar type: Specifies the type of the resource. + :vartype type: str + :param tags: Contains resource tags defined as key/value pairs. + :type tags: dict[str, str] + :param sku: Gets or sets the SKU of the resource. + :type sku: ~azure.mgmt.botservice.models.Sku + :param kind: Required. Gets or sets the Kind of the resource. Possible + values include: 'sdk', 'designer', 'bot', 'function' + :type kind: str or ~azure.mgmt.botservice.models.Kind + :param etag: Entity Tag + :type etag: str + :param properties: The set of properties specific to bot resource + :type properties: ~azure.mgmt.botservice.models.BotProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BotProperties'}, + } + + def __init__(self, location=None, tags=None, sku=None, kind=None, etag=None, properties=None): + super(Bot, self).__init__(location=location, tags=tags, sku=sku, kind=kind, etag=etag) + self.properties = properties diff --git a/src/botservice/azext_bot/botservice/models/bot_channel.py b/src/botservice/azext_bot/botservice/models/bot_channel.py new file mode 100644 index 00000000000..78b6439dcb7 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/bot_channel.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class BotChannel(Resource): + """Bot channel resource definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Specifies the resource ID. + :vartype id: str + :ivar name: Specifies the name of the resource. + :vartype name: str + :param location: Specifies the location of the resource. + :type location: str + :ivar type: Specifies the type of the resource. + :vartype type: str + :param tags: Contains resource tags defined as key/value pairs. + :type tags: dict[str, str] + :param sku: Gets or sets the SKU of the resource. + :type sku: ~azure.mgmt.botservice.models.Sku + :param kind: Required. Gets or sets the Kind of the resource. Possible + values include: 'sdk', 'designer', 'bot', 'function' + :type kind: str or ~azure.mgmt.botservice.models.Kind + :param etag: Entity Tag + :type etag: str + :param properties: The set of properties specific to bot channel resource + :type properties: ~azure.mgmt.botservice.models.Channel + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'Channel'}, + } + + def __init__(self, location=None, tags=None, sku=None, kind=None, etag=None, properties=None): + super(BotChannel, self).__init__(location=location, tags=tags, sku=sku, kind=kind, etag=etag) + self.properties = properties diff --git a/src/botservice/azext_bot/botservice/models/bot_channel_paged.py b/src/botservice/azext_bot/botservice/models/bot_channel_paged.py new file mode 100644 index 00000000000..7cf0ca71040 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/bot_channel_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class BotChannelPaged(Paged): + """ + A paging container for iterating over a list of :class:`BotChannel ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[BotChannel]'} + } + + def __init__(self, *args, **kwargs): + + super(BotChannelPaged, self).__init__(*args, **kwargs) diff --git a/src/botservice/azext_bot/botservice/models/bot_paged.py b/src/botservice/azext_bot/botservice/models/bot_paged.py new file mode 100644 index 00000000000..410e37eb94b --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/bot_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class BotPaged(Paged): + """ + A paging container for iterating over a list of :class:`Bot ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Bot]'} + } + + def __init__(self, *args, **kwargs): + + super(BotPaged, self).__init__(*args, **kwargs) diff --git a/src/botservice/azext_bot/botservice/models/bot_properties.py b/src/botservice/azext_bot/botservice/models/bot_properties.py new file mode 100644 index 00000000000..4b7e4251db5 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/bot_properties.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BotProperties(Model): + """The parameters to provide for the Bot. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param display_name: The Name of the bot + :type display_name: str + :param description: The description of the bot + :type description: str + :param icon_url: The Icon Url of the bot + :type icon_url: str + :param endpoint: The bot's endpoint + :type endpoint: str + :ivar endpoint_version: The bot's endpoint version + :vartype endpoint_version: str + :param msa_app_id: Microsoft App Id for the bot + :type msa_app_id: str + :ivar configured_channels: Collection of channels for which the bot is + configured + :vartype configured_channels: list[str] + :ivar enabled_channels: Collection of channels for which the bot is + enabled + :vartype enabled_channels: list[str] + :param developer_app_insight_key: The Application Insights key + :type developer_app_insight_key: str + :param developer_app_insights_api_key: The Application Insights Api Key + :type developer_app_insights_api_key: str + :param developer_app_insights_application_id: The Application Insights App + Id + :type developer_app_insights_application_id: str + :param luis_app_ids: Collection of LUIS App Ids + :type luis_app_ids: list[str] + :param luis_key: The LUIS Key + :type luis_key: str + """ + + _validation = { + 'display_name': {'required': True}, + 'endpoint': {'required': True}, + 'endpoint_version': {'readonly': True}, + 'msa_app_id': {'required': True}, + 'configured_channels': {'readonly': True}, + 'enabled_channels': {'readonly': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'icon_url': {'key': 'iconUrl', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + 'endpoint_version': {'key': 'endpointVersion', 'type': 'str'}, + 'msa_app_id': {'key': 'msaAppId', 'type': 'str'}, + 'configured_channels': {'key': 'configuredChannels', 'type': '[str]'}, + 'enabled_channels': {'key': 'enabledChannels', 'type': '[str]'}, + 'developer_app_insight_key': {'key': 'developerAppInsightKey', 'type': 'str'}, + 'developer_app_insights_api_key': {'key': 'developerAppInsightsApiKey', 'type': 'str'}, + 'developer_app_insights_application_id': {'key': 'developerAppInsightsApplicationId', 'type': 'str'}, + 'luis_app_ids': {'key': 'luisAppIds', 'type': '[str]'}, + 'luis_key': {'key': 'luisKey', 'type': 'str'}, + } + + def __init__(self, display_name, endpoint, msa_app_id, description=None, icon_url=None, developer_app_insight_key=None, developer_app_insights_api_key=None, developer_app_insights_application_id=None, luis_app_ids=None, luis_key=None): + self.display_name = display_name + self.description = description + self.icon_url = icon_url + self.endpoint = endpoint + self.endpoint_version = None + self.msa_app_id = msa_app_id + self.configured_channels = None + self.enabled_channels = None + self.developer_app_insight_key = developer_app_insight_key + self.developer_app_insights_api_key = developer_app_insights_api_key + self.developer_app_insights_application_id = developer_app_insights_application_id + self.luis_app_ids = luis_app_ids + self.luis_key = luis_key diff --git a/src/botservice/azext_bot/botservice/models/channel.py b/src/botservice/azext_bot/botservice/models/channel.py new file mode 100644 index 00000000000..d6b04cf2f46 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/channel.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Channel(Model): + """Channel definition. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: FacebookChannel, EmailChannel, MsTeamsChannel, + SkypeChannel, KikChannel, WebChatChannel, DirectLineChannel, + TelegramChannel, SmsChannel, SlackChannel + + :param channel_name: Constant filled by server. + :type channel_name: str + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + } + + _subtype_map = { + 'channel_name': {'FacebookChannel': 'FacebookChannel', 'EmailChannel': 'EmailChannel', 'MsTeamsChannel': 'MsTeamsChannel', 'SkypeChannel': 'SkypeChannel', 'KikChannel': 'KikChannel', 'WebChatChannel': 'WebChatChannel', 'DirectLineChannel': 'DirectLineChannel', 'TelegramChannel': 'TelegramChannel', 'SmsChannel': 'SmsChannel', 'SlackChannel': 'SlackChannel'} + } + + def __init__(self): + self.channel_name = None diff --git a/src/botservice/azext_bot/botservice/models/check_name_availability_request_body.py b/src/botservice/azext_bot/botservice/models/check_name_availability_request_body.py new file mode 100644 index 00000000000..7c78f2e00d5 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/check_name_availability_request_body.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CheckNameAvailabilityRequestBody(Model): + """The request body for a request to Bot Service Management to check + availability of a bot name. + + :param name: the name of the bot for which availability needs to be + checked. + :type name: str + :param type: the type of the bot for which availability needs to be + checked + :type type: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, name=None, type=None): + self.name = name + self.type = type diff --git a/src/botservice/azext_bot/botservice/models/check_name_availability_response_body.py b/src/botservice/azext_bot/botservice/models/check_name_availability_response_body.py new file mode 100644 index 00000000000..4e1313f2f5e --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/check_name_availability_response_body.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CheckNameAvailabilityResponseBody(Model): + """The response body returned for a request to Bot Service Management to check + availability of a bot name. + + :param valid: indicates if the bot name is valid. + :type valid: bool + :param message: additional message from the bot management api showing why + a bot name is not available + :type message: str + """ + + _attribute_map = { + 'valid': {'key': 'valid', 'type': 'bool'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, valid=None, message=None): + self.valid = valid + self.message = message diff --git a/src/botservice/azext_bot/botservice/models/direct_line_channel.py b/src/botservice/azext_bot/botservice/models/direct_line_channel.py new file mode 100644 index 00000000000..43af144b6f0 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/direct_line_channel.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class DirectLineChannel(Channel): + """Direct Line channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to Direct Line channel + resource + :type properties: + ~azure.mgmt.botservice.models.DirectLineChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DirectLineChannelProperties'}, + } + + def __init__(self, properties=None): + super(DirectLineChannel, self).__init__() + self.properties = properties + self.channel_name = 'DirectLineChannel' diff --git a/src/botservice/azext_bot/botservice/models/direct_line_channel_properties.py b/src/botservice/azext_bot/botservice/models/direct_line_channel_properties.py new file mode 100644 index 00000000000..537e8b44ea9 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/direct_line_channel_properties.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DirectLineChannelProperties(Model): + """The parameters to provide for the Direct Line channel. + + :param sites: The list of Direct Line sites + :type sites: list[~azure.mgmt.botservice.models.DirectLineSite] + """ + + _attribute_map = { + 'sites': {'key': 'sites', 'type': '[DirectLineSite]'}, + } + + def __init__(self, sites=None): + self.sites = sites diff --git a/src/botservice/azext_bot/botservice/models/direct_line_site.py b/src/botservice/azext_bot/botservice/models/direct_line_site.py new file mode 100644 index 00000000000..c57b449638c --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/direct_line_site.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DirectLineSite(Model): + """A site for the Direct Line channel. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar site_id: Site Id + :vartype site_id: str + :param site_name: Site name + :type site_name: str + :ivar key: Primary key. Value only returned through POST to the action + Channel List API, otherwise empty. + :vartype key: str + :ivar key2: Secondary key. Value only returned through POST to the action + Channel List API, otherwise empty. + :vartype key2: str + :param is_enabled: Whether this site is enabled for DirectLine channel + :type is_enabled: bool + :param is_v1_enabled: Whether this site is enabled for Bot Framework V1 + protocol + :type is_v1_enabled: bool + :param is_v3_enabled: Whether this site is enabled for Bot Framework V1 + protocol + :type is_v3_enabled: bool + """ + + _validation = { + 'site_id': {'readonly': True}, + 'site_name': {'required': True}, + 'key': {'readonly': True}, + 'key2': {'readonly': True}, + 'is_enabled': {'required': True}, + 'is_v1_enabled': {'required': True}, + 'is_v3_enabled': {'required': True}, + } + + _attribute_map = { + 'site_id': {'key': 'siteId', 'type': 'str'}, + 'site_name': {'key': 'siteName', 'type': 'str'}, + 'key': {'key': 'key', 'type': 'str'}, + 'key2': {'key': 'key2', 'type': 'str'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + 'is_v1_enabled': {'key': 'isV1Enabled', 'type': 'bool'}, + 'is_v3_enabled': {'key': 'isV3Enabled', 'type': 'bool'}, + } + + def __init__(self, site_name, is_enabled, is_v1_enabled, is_v3_enabled): + self.site_id = None + self.site_name = site_name + self.key = None + self.key2 = None + self.is_enabled = is_enabled + self.is_v1_enabled = is_v1_enabled + self.is_v3_enabled = is_v3_enabled diff --git a/src/botservice/azext_bot/botservice/models/email_channel.py b/src/botservice/azext_bot/botservice/models/email_channel.py new file mode 100644 index 00000000000..d8b1cf9f46a --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/email_channel.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class EmailChannel(Channel): + """Email channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to email channel + resource + :type properties: ~azure.mgmt.botservice.models.EmailChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'EmailChannelProperties'}, + } + + def __init__(self, properties=None): + super(EmailChannel, self).__init__() + self.properties = properties + self.channel_name = 'EmailChannel' diff --git a/src/botservice/azext_bot/botservice/models/email_channel_properties.py b/src/botservice/azext_bot/botservice/models/email_channel_properties.py new file mode 100644 index 00000000000..721ad21f911 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/email_channel_properties.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class EmailChannelProperties(Model): + """The parameters to provide for the Email channel. + + :param email_address: The email address + :type email_address: str + :param password: The password for the email address. Value only returned + through POST to the action Channel List API, otherwise empty. + :type password: str + :param is_enabled: Whether this channel is enabled for the bot + :type is_enabled: bool + """ + + _validation = { + 'email_address': {'required': True}, + 'password': {'required': True}, + 'is_enabled': {'required': True}, + } + + _attribute_map = { + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + } + + def __init__(self, email_address, password, is_enabled): + self.email_address = email_address + self.password = password + self.is_enabled = is_enabled diff --git a/src/botservice/azext_bot/botservice/models/error.py b/src/botservice/azext_bot/botservice/models/error.py new file mode 100644 index 00000000000..019e466cd62 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/error.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class Error(Model): + """Bot Service error object. + + :param error: The error body. + :type error: ~azure.mgmt.botservice.models.ErrorBody + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorBody'}, + } + + def __init__(self, error=None): + self.error = error + + +class ErrorException(HttpOperationError): + """Server responsed with exception of type: 'Error'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorException, self).__init__(deserialize, response, 'Error', *args) diff --git a/src/botservice/azext_bot/botservice/models/error_body.py b/src/botservice/azext_bot/botservice/models/error_body.py new file mode 100644 index 00000000000..926be9c3b94 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/error_body.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ErrorBody(Model): + """Bot Service error body. + + :param code: error code + :type code: str + :param message: error message + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, code, message): + self.code = code + self.message = message diff --git a/src/botservice/azext_bot/botservice/models/facebook_channel.py b/src/botservice/azext_bot/botservice/models/facebook_channel.py new file mode 100644 index 00000000000..b253e2fb1f4 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/facebook_channel.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class FacebookChannel(Channel): + """Facebook channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to bot facebook channel + :type properties: ~azure.mgmt.botservice.models.FacebookChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'FacebookChannelProperties'}, + } + + def __init__(self, properties=None): + super(FacebookChannel, self).__init__() + self.properties = properties + self.channel_name = 'FacebookChannel' diff --git a/src/botservice/azext_bot/botservice/models/facebook_channel_properties.py b/src/botservice/azext_bot/botservice/models/facebook_channel_properties.py new file mode 100644 index 00000000000..0869c34a0af --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/facebook_channel_properties.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FacebookChannelProperties(Model): + """The parameters to provide for the Facebook channel. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar verify_token: Verify token. Value only returned through POST to the + action Channel List API, otherwise empty. + :vartype verify_token: str + :param pages: The list of Facebook pages + :type pages: list[~azure.mgmt.botservice.models.FacebookPage] + :param app_id: Facebook application id + :type app_id: str + :param app_secret: Facebook application secret. Value only returned + through POST to the action Channel List API, otherwise empty. + :type app_secret: str + :ivar callback_url: Callback Url + :vartype callback_url: str + :param is_enabled: Whether this channel is enabled for the bot + :type is_enabled: bool + """ + + _validation = { + 'verify_token': {'readonly': True}, + 'app_id': {'required': True}, + 'app_secret': {'required': True}, + 'callback_url': {'readonly': True}, + 'is_enabled': {'required': True}, + } + + _attribute_map = { + 'verify_token': {'key': 'verifyToken', 'type': 'str'}, + 'pages': {'key': 'pages', 'type': '[FacebookPage]'}, + 'app_id': {'key': 'appId', 'type': 'str'}, + 'app_secret': {'key': 'appSecret', 'type': 'str'}, + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + } + + def __init__(self, app_id, app_secret, is_enabled, pages=None): + self.verify_token = None + self.pages = pages + self.app_id = app_id + self.app_secret = app_secret + self.callback_url = None + self.is_enabled = is_enabled diff --git a/src/botservice/azext_bot/botservice/models/facebook_page.py b/src/botservice/azext_bot/botservice/models/facebook_page.py new file mode 100644 index 00000000000..aba0dcf9cd2 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/facebook_page.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FacebookPage(Model): + """A Facebook page for Facebook channel registration. + + :param id: Page id + :type id: str + :param access_token: Facebook application access token. Value only + returned through POST to the action Channel List API, otherwise empty. + :type access_token: str + """ + + _validation = { + 'id': {'required': True}, + 'access_token': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'access_token': {'key': 'accessToken', 'type': 'str'}, + } + + def __init__(self, id, access_token): + self.id = id + self.access_token = access_token diff --git a/src/botservice/azext_bot/botservice/models/kik_channel.py b/src/botservice/azext_bot/botservice/models/kik_channel.py new file mode 100644 index 00000000000..e3fe47a1b21 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/kik_channel.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class KikChannel(Channel): + """Kik channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to Kik channel resource + :type properties: ~azure.mgmt.botservice.models.KikChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'KikChannelProperties'}, + } + + def __init__(self, properties=None): + super(KikChannel, self).__init__() + self.properties = properties + self.channel_name = 'KikChannel' diff --git a/src/botservice/azext_bot/botservice/models/kik_channel_properties.py b/src/botservice/azext_bot/botservice/models/kik_channel_properties.py new file mode 100644 index 00000000000..ae0c3cc3c5a --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/kik_channel_properties.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class KikChannelProperties(Model): + """The parameters to provide for the Kik channel. + + :param user_name: The Kik user name + :type user_name: str + :param api_key: Kik API key. Value only returned through POST to the + action Channel List API, otherwise empty. + :type api_key: str + :param is_validated: Whether this channel is validated for the bot + :type is_validated: bool + :param is_enabled: Whether this channel is enabled for the bot + :type is_enabled: bool + """ + + _validation = { + 'user_name': {'required': True}, + 'api_key': {'required': True}, + 'is_enabled': {'required': True}, + } + + _attribute_map = { + 'user_name': {'key': 'userName', 'type': 'str'}, + 'api_key': {'key': 'apiKey', 'type': 'str'}, + 'is_validated': {'key': 'isValidated', 'type': 'bool'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + } + + def __init__(self, user_name, api_key, is_enabled, is_validated=None): + self.user_name = user_name + self.api_key = api_key + self.is_validated = is_validated + self.is_enabled = is_enabled diff --git a/src/botservice/azext_bot/botservice/models/ms_teams_channel.py b/src/botservice/azext_bot/botservice/models/ms_teams_channel.py new file mode 100644 index 00000000000..c5a9c0b932e --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/ms_teams_channel.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class MsTeamsChannel(Channel): + """Microsoft Teams channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to Microsoft Teams + channel resource + :type properties: ~azure.mgmt.botservice.models.MsTeamsChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'MsTeamsChannelProperties'}, + } + + def __init__(self, properties=None): + super(MsTeamsChannel, self).__init__() + self.properties = properties + self.channel_name = 'MsTeamsChannel' diff --git a/src/botservice/azext_bot/botservice/models/ms_teams_channel_properties.py b/src/botservice/azext_bot/botservice/models/ms_teams_channel_properties.py new file mode 100644 index 00000000000..51bbe2bbed2 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/ms_teams_channel_properties.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class MsTeamsChannelProperties(Model): + """The parameters to provide for the Microsoft Teams channel. + + :param enable_messaging: Enable messaging for Microsoft Teams channel + :type enable_messaging: bool + :param enable_media_cards: Enable media cards for Microsoft Teams channel + :type enable_media_cards: bool + :param enable_video: Enable video for Microsoft Teams channel + :type enable_video: bool + :param enable_calling: Enable calling for Microsoft Teams channel + :type enable_calling: bool + :param call_mode: Enable messaging for Microsoft Teams channel + :type call_mode: str + :param is_enabled: Whether this channel is enabled for the bot + :type is_enabled: bool + """ + + _validation = { + 'is_enabled': {'required': True}, + } + + _attribute_map = { + 'enable_messaging': {'key': 'enableMessaging', 'type': 'bool'}, + 'enable_media_cards': {'key': 'enableMediaCards', 'type': 'bool'}, + 'enable_video': {'key': 'enableVideo', 'type': 'bool'}, + 'enable_calling': {'key': 'enableCalling', 'type': 'bool'}, + 'call_mode': {'key': 'callMode', 'type': 'str'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + } + + def __init__(self, is_enabled, enable_messaging=None, enable_media_cards=None, enable_video=None, enable_calling=None, call_mode=None): + self.enable_messaging = enable_messaging + self.enable_media_cards = enable_media_cards + self.enable_video = enable_video + self.enable_calling = enable_calling + self.call_mode = call_mode + self.is_enabled = is_enabled diff --git a/src/botservice/azext_bot/botservice/models/operation_display_info.py b/src/botservice/azext_bot/botservice/models/operation_display_info.py new file mode 100644 index 00000000000..4be59cd2d4b --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/operation_display_info.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class OperationDisplayInfo(Model): + """The operation supported by Bot Service Management. + + :param description: The description of the operation. + :type description: str + :param operation: The action that users can perform, based on their + permission level. + :type operation: str + :param provider: Service provider: Microsoft Bot Service. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + } + + def __init__(self, description=None, operation=None, provider=None, resource=None): + self.description = description + self.operation = operation + self.provider = provider + self.resource = resource diff --git a/src/botservice/azext_bot/botservice/models/operation_entity.py b/src/botservice/azext_bot/botservice/models/operation_entity.py new file mode 100644 index 00000000000..37922e24676 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/operation_entity.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class OperationEntity(Model): + """The operations supported by Bot Service Management. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The operation supported by Bot Service Management. + :type display: ~azure.mgmt.botservice.models.OperationDisplayInfo + :param origin: The origin of the operation. + :type origin: str + :param properties: Additional properties. + :type properties: object + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'object'}, + } + + def __init__(self, name=None, display=None, origin=None, properties=None): + self.name = name + self.display = display + self.origin = origin + self.properties = properties diff --git a/src/botservice/azext_bot/botservice/models/operation_entity_paged.py b/src/botservice/azext_bot/botservice/models/operation_entity_paged.py new file mode 100644 index 00000000000..f9016021095 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/operation_entity_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class OperationEntityPaged(Paged): + """ + A paging container for iterating over a list of :class:`OperationEntity ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[OperationEntity]'} + } + + def __init__(self, *args, **kwargs): + + super(OperationEntityPaged, self).__init__(*args, **kwargs) diff --git a/src/botservice/azext_bot/botservice/models/resource.py b/src/botservice/azext_bot/botservice/models/resource.py new file mode 100644 index 00000000000..668f18a1c16 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/resource.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Resource(Model): + """Azure resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Specifies the resource ID. + :vartype id: str + :ivar name: Specifies the name of the resource. + :vartype name: str + :param location: Specifies the location of the resource. + :type location: str + :ivar type: Specifies the type of the resource. + :vartype type: str + :param tags: Contains resource tags defined as key/value pairs. + :type tags: dict[str, str] + :param sku: Gets or sets the SKU of the resource. + :type sku: ~azure.mgmt.botservice.models.Sku + :param kind: Required. Gets or sets the Kind of the resource. Possible + values include: 'sdk', 'designer', 'bot', 'function' + :type kind: str or ~azure.mgmt.botservice.models.Kind + :param etag: Entity Tag + :type etag: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, location=None, tags=None, sku=None, kind=None, etag=None): + self.id = None + self.name = None + self.location = location + self.type = None + self.tags = tags + self.sku = sku + self.kind = kind + self.etag = etag diff --git a/src/botservice/azext_bot/botservice/models/sku.py b/src/botservice/azext_bot/botservice/models/sku.py new file mode 100644 index 00000000000..35fa9c14224 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/sku.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Sku(Model): + """The SKU of the cognitive services account. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param name: The sku name. Possible values include: 'F0', 'S1' + :type name: str or ~azure.mgmt.botservice.models.SkuName + :ivar tier: Gets the sku tier. This is based on the SKU name. Possible + values include: 'Free', 'Standard' + :vartype tier: str or ~azure.mgmt.botservice.models.SkuTier + """ + + _validation = { + 'name': {'required': True}, + 'tier': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + } + + def __init__(self, name): + self.name = name + self.tier = None diff --git a/src/botservice/azext_bot/botservice/models/skype_channel.py b/src/botservice/azext_bot/botservice/models/skype_channel.py new file mode 100644 index 00000000000..f9c12c31dd0 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/skype_channel.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class SkypeChannel(Channel): + """Skype channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to Skype channel + resource + :type properties: ~azure.mgmt.botservice.models.SkypeChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'SkypeChannelProperties'}, + } + + def __init__(self, properties=None): + super(SkypeChannel, self).__init__() + self.properties = properties + self.channel_name = 'SkypeChannel' diff --git a/src/botservice/azext_bot/botservice/models/skype_channel_properties.py b/src/botservice/azext_bot/botservice/models/skype_channel_properties.py new file mode 100644 index 00000000000..582d94c4869 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/skype_channel_properties.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SkypeChannelProperties(Model): + """The parameters to provide for the Microsoft Teams channel. + + :param enable_messaging: Enable messaging for Skype channel + :type enable_messaging: bool + :param enable_media_cards: Enable media cards for Skype channel + :type enable_media_cards: bool + :param enable_video: Enable video for Skype channel + :type enable_video: bool + :param enable_calling: Enable calling for Skype channel + :type enable_calling: bool + :param enable_screen_sharing: Enable screen sharing for Skype channel + :type enable_screen_sharing: bool + :param enable_groups: Enable groups for Skype channel + :type enable_groups: bool + :param groups_mode: Group mode for Skype channel + :type groups_mode: str + :param calling_web_hook: Calling web hook for Skype channel + :type calling_web_hook: str + :param is_enabled: Whether this channel is enabled for the bot + :type is_enabled: bool + """ + + _validation = { + 'is_enabled': {'required': True}, + } + + _attribute_map = { + 'enable_messaging': {'key': 'enableMessaging', 'type': 'bool'}, + 'enable_media_cards': {'key': 'enableMediaCards', 'type': 'bool'}, + 'enable_video': {'key': 'enableVideo', 'type': 'bool'}, + 'enable_calling': {'key': 'enableCalling', 'type': 'bool'}, + 'enable_screen_sharing': {'key': 'enableScreenSharing', 'type': 'bool'}, + 'enable_groups': {'key': 'enableGroups', 'type': 'bool'}, + 'groups_mode': {'key': 'groupsMode', 'type': 'str'}, + 'calling_web_hook': {'key': 'callingWebHook', 'type': 'str'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + } + + def __init__(self, is_enabled, enable_messaging=None, enable_media_cards=None, enable_video=None, enable_calling=None, enable_screen_sharing=None, enable_groups=None, groups_mode=None, calling_web_hook=None): + self.enable_messaging = enable_messaging + self.enable_media_cards = enable_media_cards + self.enable_video = enable_video + self.enable_calling = enable_calling + self.enable_screen_sharing = enable_screen_sharing + self.enable_groups = enable_groups + self.groups_mode = groups_mode + self.calling_web_hook = calling_web_hook + self.is_enabled = is_enabled diff --git a/src/botservice/azext_bot/botservice/models/slack_channel.py b/src/botservice/azext_bot/botservice/models/slack_channel.py new file mode 100644 index 00000000000..7be5bd512b2 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/slack_channel.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class SlackChannel(Channel): + """Slack channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to Slack channel + resource + :type properties: ~azure.mgmt.botservice.models.SlackChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'SlackChannelProperties'}, + } + + def __init__(self, properties=None): + super(SlackChannel, self).__init__() + self.properties = properties + self.channel_name = 'SlackChannel' diff --git a/src/botservice/azext_bot/botservice/models/slack_channel_properties.py b/src/botservice/azext_bot/botservice/models/slack_channel_properties.py new file mode 100644 index 00000000000..3eee419dce6 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/slack_channel_properties.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SlackChannelProperties(Model): + """The parameters to provide for the Slack channel. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param client_id: The Slack client id + :type client_id: str + :param client_secret: The Slack client secret. Value only returned through + POST to the action Channel List API, otherwise empty. + :type client_secret: str + :param verification_token: The Slack verification token. Value only + returned through POST to the action Channel List API, otherwise empty. + :type verification_token: str + :param landing_page_url: The Slack landing page Url + :type landing_page_url: str + :ivar redirect_action: The Slack redirect action + :vartype redirect_action: str + :ivar last_submission_id: The Sms auth token + :vartype last_submission_id: str + :ivar register_before_oauth_flow: Whether to register the settings before + OAuth validation is performed. Recommended to True. + :vartype register_before_oauth_flow: bool + :ivar is_validated: Whether this channel is validated for the bot + :vartype is_validated: bool + :param is_enabled: Whether this channel is enabled for the bot + :type is_enabled: bool + """ + + _validation = { + 'client_id': {'required': True}, + 'client_secret': {'required': True}, + 'verification_token': {'required': True}, + 'redirect_action': {'readonly': True}, + 'last_submission_id': {'readonly': True}, + 'register_before_oauth_flow': {'readonly': True}, + 'is_validated': {'readonly': True}, + 'is_enabled': {'required': True}, + } + + _attribute_map = { + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + 'verification_token': {'key': 'verificationToken', 'type': 'str'}, + 'landing_page_url': {'key': 'landingPageUrl', 'type': 'str'}, + 'redirect_action': {'key': 'redirectAction', 'type': 'str'}, + 'last_submission_id': {'key': 'lastSubmissionId', 'type': 'str'}, + 'register_before_oauth_flow': {'key': 'registerBeforeOAuthFlow', 'type': 'bool'}, + 'is_validated': {'key': 'isValidated', 'type': 'bool'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + } + + def __init__(self, client_id, client_secret, verification_token, is_enabled, landing_page_url=None): + self.client_id = client_id + self.client_secret = client_secret + self.verification_token = verification_token + self.landing_page_url = landing_page_url + self.redirect_action = None + self.last_submission_id = None + self.register_before_oauth_flow = None + self.is_validated = None + self.is_enabled = is_enabled diff --git a/src/botservice/azext_bot/botservice/models/sms_channel.py b/src/botservice/azext_bot/botservice/models/sms_channel.py new file mode 100644 index 00000000000..dba9ebc8363 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/sms_channel.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class SmsChannel(Channel): + """Sms channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to Sms channel resource + :type properties: ~azure.mgmt.botservice.models.SmsChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'SmsChannelProperties'}, + } + + def __init__(self, properties=None): + super(SmsChannel, self).__init__() + self.properties = properties + self.channel_name = 'SmsChannel' diff --git a/src/botservice/azext_bot/botservice/models/sms_channel_properties.py b/src/botservice/azext_bot/botservice/models/sms_channel_properties.py new file mode 100644 index 00000000000..7602eba2daa --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/sms_channel_properties.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SmsChannelProperties(Model): + """The parameters to provide for the Sms channel. + + :param phone: The Sms phone + :type phone: str + :param account_sid: The Sms account SID. Value only returned through POST + to the action Channel List API, otherwise empty. + :type account_sid: str + :param auth_token: The Sms auth token. Value only returned through POST to + the action Channel List API, otherwise empty. + :type auth_token: str + :param is_validated: Whether this channel is validated for the bot + :type is_validated: bool + :param is_enabled: Whether this channel is enabled for the bot + :type is_enabled: bool + """ + + _validation = { + 'phone': {'required': True}, + 'account_sid': {'required': True}, + 'auth_token': {'required': True}, + 'is_enabled': {'required': True}, + } + + _attribute_map = { + 'phone': {'key': 'phone', 'type': 'str'}, + 'account_sid': {'key': 'accountSID', 'type': 'str'}, + 'auth_token': {'key': 'authToken', 'type': 'str'}, + 'is_validated': {'key': 'isValidated', 'type': 'bool'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + } + + def __init__(self, phone, account_sid, auth_token, is_enabled, is_validated=None): + self.phone = phone + self.account_sid = account_sid + self.auth_token = auth_token + self.is_validated = is_validated + self.is_enabled = is_enabled diff --git a/src/botservice/azext_bot/botservice/models/telegram_channel.py b/src/botservice/azext_bot/botservice/models/telegram_channel.py new file mode 100644 index 00000000000..eb2afc7e87b --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/telegram_channel.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class TelegramChannel(Channel): + """Telegram channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to Telegram channel + resource + :type properties: ~azure.mgmt.botservice.models.TelegramChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'TelegramChannelProperties'}, + } + + def __init__(self, properties=None): + super(TelegramChannel, self).__init__() + self.properties = properties + self.channel_name = 'TelegramChannel' diff --git a/src/botservice/azext_bot/botservice/models/telegram_channel_properties.py b/src/botservice/azext_bot/botservice/models/telegram_channel_properties.py new file mode 100644 index 00000000000..ccdec8e2d7d --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/telegram_channel_properties.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class TelegramChannelProperties(Model): + """The parameters to provide for the Telegram channel. + + :param access_token: The Telegram access token. Value only returned + through POST to the action Channel List API, otherwise empty. + :type access_token: str + :param is_validated: Whether this channel is validated for the bot + :type is_validated: bool + :param is_enabled: Whether this channel is enabled for the bot + :type is_enabled: bool + """ + + _validation = { + 'access_token': {'required': True}, + 'is_enabled': {'required': True}, + } + + _attribute_map = { + 'access_token': {'key': 'accessToken', 'type': 'str'}, + 'is_validated': {'key': 'isValidated', 'type': 'bool'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + } + + def __init__(self, access_token, is_enabled, is_validated=None): + self.access_token = access_token + self.is_validated = is_validated + self.is_enabled = is_enabled diff --git a/src/botservice/azext_bot/botservice/models/web_chat_channel.py b/src/botservice/azext_bot/botservice/models/web_chat_channel.py new file mode 100644 index 00000000000..e2fc362fdb6 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/web_chat_channel.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .channel import Channel + + +class WebChatChannel(Channel): + """Web Chat channel definition. + + :param channel_name: Constant filled by server. + :type channel_name: str + :param properties: The set of properties specific to Web Chat channel + resource + :type properties: ~azure.mgmt.botservice.models.WebChatChannelProperties + """ + + _validation = { + 'channel_name': {'required': True}, + } + + _attribute_map = { + 'channel_name': {'key': 'channelName', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'WebChatChannelProperties'}, + } + + def __init__(self, properties=None): + super(WebChatChannel, self).__init__() + self.properties = properties + self.channel_name = 'WebChatChannel' diff --git a/src/botservice/azext_bot/botservice/models/web_chat_channel_properties.py b/src/botservice/azext_bot/botservice/models/web_chat_channel_properties.py new file mode 100644 index 00000000000..144b64707a6 --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/web_chat_channel_properties.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class WebChatChannelProperties(Model): + """The parameters to provide for the Web Chat channel. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar web_chat_embed_code: Web chat control embed code + :vartype web_chat_embed_code: str + :param sites: The list of Web Chat sites + :type sites: list[~azure.mgmt.botservice.models.WebChatSite] + """ + + _validation = { + 'web_chat_embed_code': {'readonly': True}, + } + + _attribute_map = { + 'web_chat_embed_code': {'key': 'webChatEmbedCode', 'type': 'str'}, + 'sites': {'key': 'sites', 'type': '[WebChatSite]'}, + } + + def __init__(self, sites=None): + self.web_chat_embed_code = None + self.sites = sites diff --git a/src/botservice/azext_bot/botservice/models/web_chat_site.py b/src/botservice/azext_bot/botservice/models/web_chat_site.py new file mode 100644 index 00000000000..6684d4cf18c --- /dev/null +++ b/src/botservice/azext_bot/botservice/models/web_chat_site.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class WebChatSite(Model): + """A site for the Webchat channel. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar site_id: Site Id + :vartype site_id: str + :param site_name: Site name + :type site_name: str + :ivar key: Primary key. Value only returned through POST to the action + Channel List API, otherwise empty. + :vartype key: str + :ivar key2: Secondary key. Value only returned through POST to the action + Channel List API, otherwise empty. + :vartype key2: str + :param is_enabled: Whether this site is enabled for DirectLine channel + :type is_enabled: bool + :param enable_preview: Whether this site is enabled for preview versions + of Webchat + :type enable_preview: bool + """ + + _validation = { + 'site_id': {'readonly': True}, + 'site_name': {'required': True}, + 'key': {'readonly': True}, + 'key2': {'readonly': True}, + 'is_enabled': {'required': True}, + 'enable_preview': {'required': True}, + } + + _attribute_map = { + 'site_id': {'key': 'siteId', 'type': 'str'}, + 'site_name': {'key': 'siteName', 'type': 'str'}, + 'key': {'key': 'key', 'type': 'str'}, + 'key2': {'key': 'key2', 'type': 'str'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + 'enable_preview': {'key': 'enablePreview', 'type': 'bool'}, + } + + def __init__(self, site_name, is_enabled, enable_preview): + self.site_id = None + self.site_name = site_name + self.key = None + self.key2 = None + self.is_enabled = is_enabled + self.enable_preview = enable_preview diff --git a/src/botservice/azext_bot/botservice/operations/__init__.py b/src/botservice/azext_bot/botservice/operations/__init__.py new file mode 100644 index 00000000000..a587b5bcc9f --- /dev/null +++ b/src/botservice/azext_bot/botservice/operations/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .bots_operations import BotsOperations +from .channels_operations import ChannelsOperations +from .operations import Operations + +__all__ = [ + 'BotsOperations', + 'ChannelsOperations', + 'Operations', +] diff --git a/src/botservice/azext_bot/botservice/operations/bots_operations.py b/src/botservice/azext_bot/botservice/operations/bots_operations.py new file mode 100644 index 00000000000..6c198db96d6 --- /dev/null +++ b/src/botservice/azext_bot/botservice/operations/bots_operations.py @@ -0,0 +1,499 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class BotsOperations(object): + """BotsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + :ivar api_version: Version of the API to be used with the client request. Current version is 2017-12-01. Constant value: "2017-12-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-12-01" + + self.config = config + + def create( + self, resource_group_name, resource_name, parameters, custom_headers=None, raw=False, **operation_config): + """Creates a Bot Service. Bot Service is a resource group wide resource + type. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param parameters: The parameters to provide for the created bot. + :type parameters: ~azure.mgmt.botservice.models.Bot + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Bot or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.botservice.models.Bot or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'Bot') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Bot', response) + if response.status_code == 201: + deserialized = self._deserialize('Bot', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, resource_name, location=None, tags=None, sku=None, kind=None, etag=None, properties=None, custom_headers=None, raw=False, **operation_config): + """Updates a Bot Service. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param location: Specifies the location of the resource. + :type location: str + :param tags: Contains resource tags defined as key/value pairs. + :type tags: dict[str, str] + :param sku: Gets or sets the SKU of the resource. + :type sku: ~azure.mgmt.botservice.models.Sku + :param kind: Required. Gets or sets the Kind of the resource. Possible + values include: 'sdk', 'designer', 'bot', 'function' + :type kind: str or ~azure.mgmt.botservice.models.Kind + :param etag: Entity Tag + :type etag: str + :param properties: The set of properties specific to bot resource + :type properties: ~azure.mgmt.botservice.models.BotProperties + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Bot or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.botservice.models.Bot or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + parameters = models.Bot(location=location, tags=tags, sku=sku, kind=kind, etag=etag, properties=properties) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'Bot') + + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Bot', response) + if response.status_code == 201: + deserialized = self._deserialize('Bot', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def delete( + self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): + """Deletes a Bot Service from the resource group. . + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200, 204]: + raise models.ErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def get( + self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): + """Returns a BotService specified by the parameters. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Bot or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.botservice.models.Bot or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Bot', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def list_by_resource_group( + self, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Returns all the resources of a particular type belonging to a resource + group. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Bot + :rtype: + ~azure.mgmt.botservice.models.BotPaged[~azure.mgmt.botservice.models.Bot] + :raises: + :class:`ErrorException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.BotPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.BotPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Returns all the resources of a particular type belonging to a + subscription. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Bot + :rtype: + ~azure.mgmt.botservice.models.BotPaged[~azure.mgmt.botservice.models.Bot] + :raises: + :class:`ErrorException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/providers/Microsoft.BotService/botServices' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.BotPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.BotPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def get_check_name_availability( + self, name=None, type=None, custom_headers=None, raw=False, **operation_config): + """Check whether a bot name is available. + + :param name: the name of the bot for which availability needs to be + checked. + :type name: str + :param type: the type of the bot for which availability needs to be + checked + :type type: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: CheckNameAvailabilityResponseBody or ClientRawResponse if + raw=true + :rtype: + ~azure.mgmt.botservice.models.CheckNameAvailabilityResponseBody or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + parameters = models.CheckNameAvailabilityRequestBody(name=name, type=type) + + # Construct URL + url = '/providers/Microsoft.BotService/botServices/checkNameAvailability' + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'CheckNameAvailabilityRequestBody') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CheckNameAvailabilityResponseBody', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized diff --git a/src/botservice/azext_bot/botservice/operations/channels_operations.py b/src/botservice/azext_bot/botservice/operations/channels_operations.py new file mode 100644 index 00000000000..eada70665df --- /dev/null +++ b/src/botservice/azext_bot/botservice/operations/channels_operations.py @@ -0,0 +1,459 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class ChannelsOperations(object): + """ChannelsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + :ivar api_version: Version of the API to be used with the client request. Current version is 2017-12-01. Constant value: "2017-12-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-12-01" + + self.config = config + + def create( + self, resource_group_name, resource_name, channel_name, parameters, custom_headers=None, raw=False, **operation_config): + """Creates a Channel registration for a Bot Service. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param channel_name: The name of the Channel resource. Possible values + include: 'FacebookChannel', 'EmailChannel', 'KikChannel', + 'TelegramChannel', 'SlackChannel', 'MsTeamsChannel', 'SkypeChannel', + 'WebChatChannel', 'DirectLineChannel', 'SmsChannel' + :type channel_name: str or ~azure.mgmt.botservice.models.ChannelName + :param parameters: The parameters to provide for the created bot. + :type parameters: ~azure.mgmt.botservice.models.BotChannel + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: BotChannel or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.botservice.models.BotChannel or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'channelName': self._serialize.url("channel_name", channel_name, 'ChannelName'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'BotChannel') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('BotChannel', response) + if response.status_code == 201: + deserialized = self._deserialize('BotChannel', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, resource_name, channel_name, location=None, tags=None, sku=None, kind=None, etag=None, properties=None, custom_headers=None, raw=False, **operation_config): + """Updates a Channel registration for a Bot Service. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param channel_name: The name of the Channel resource. Possible values + include: 'FacebookChannel', 'EmailChannel', 'KikChannel', + 'TelegramChannel', 'SlackChannel', 'MsTeamsChannel', 'SkypeChannel', + 'WebChatChannel', 'DirectLineChannel', 'SmsChannel' + :type channel_name: str or ~azure.mgmt.botservice.models.ChannelName + :param location: Specifies the location of the resource. + :type location: str + :param tags: Contains resource tags defined as key/value pairs. + :type tags: dict[str, str] + :param sku: Gets or sets the SKU of the resource. + :type sku: ~azure.mgmt.botservice.models.Sku + :param kind: Required. Gets or sets the Kind of the resource. Possible + values include: 'sdk', 'designer', 'bot', 'function' + :type kind: str or ~azure.mgmt.botservice.models.Kind + :param etag: Entity Tag + :type etag: str + :param properties: The set of properties specific to bot channel + resource + :type properties: ~azure.mgmt.botservice.models.Channel + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: BotChannel or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.botservice.models.BotChannel or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + parameters = models.BotChannel(location=location, tags=tags, sku=sku, kind=kind, etag=etag, properties=properties) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'channelName': self._serialize.url("channel_name", channel_name, 'ChannelName'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'BotChannel') + + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('BotChannel', response) + if response.status_code == 201: + deserialized = self._deserialize('BotChannel', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def delete( + self, resource_group_name, resource_name, channel_name, custom_headers=None, raw=False, **operation_config): + """Deletes a Channel registration from a Bot Service. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param channel_name: The name of the Bot resource. + :type channel_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'channelName': self._serialize.url("channel_name", channel_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200, 204]: + raise models.ErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def get( + self, resource_group_name, resource_name, channel_name, custom_headers=None, raw=False, **operation_config): + """Returns a BotService Channel registration specified by the parameters. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param channel_name: The name of the Bot resource. + :type channel_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: BotChannel or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.botservice.models.BotChannel or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'channelName': self._serialize.url("channel_name", channel_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('BotChannel', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def list_with_keys( + self, resource_group_name, resource_name, channel_name, custom_headers=None, raw=False, **operation_config): + """Lists a Channel registration for a Bot Service including secrets. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param channel_name: The name of the Channel resource. Possible values + include: 'FacebookChannel', 'EmailChannel', 'KikChannel', + 'TelegramChannel', 'SlackChannel', 'MsTeamsChannel', 'SkypeChannel', + 'WebChatChannel', 'DirectLineChannel', 'SmsChannel' + :type channel_name: str or ~azure.mgmt.botservice.models.ChannelName + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: BotChannel or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.botservice.models.BotChannel or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}/listChannelWithKeys' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'channelName': self._serialize.url("channel_name", channel_name, 'ChannelName'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('BotChannel', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def list_by_resource_group( + self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): + """Returns all the Channel registrations of a particular BotService + resource. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param resource_name: The name of the Bot resource. + :type resource_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of BotChannel + :rtype: + ~azure.mgmt.botservice.models.BotChannelPaged[~azure.mgmt.botservice.models.BotChannel] + :raises: + :class:`ErrorException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.BotChannelPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.BotChannelPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized diff --git a/src/botservice/azext_bot/botservice/operations/operations.py b/src/botservice/azext_bot/botservice/operations/operations.py new file mode 100644 index 00000000000..87663ae547e --- /dev/null +++ b/src/botservice/azext_bot/botservice/operations/operations.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class Operations(object): + """Operations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + :ivar api_version: Version of the API to be used with the client request. Current version is 2017-12-01. Constant value: "2017-12-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-12-01" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Lists all the available BotService operations. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of OperationEntity + :rtype: + ~azure.mgmt.botservice.models.OperationEntityPaged[~azure.mgmt.botservice.models.OperationEntity] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/providers/Microsoft.BotService/operations' + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + deserialized = models.OperationEntityPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.OperationEntityPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized diff --git a/src/botservice/azext_bot/botservice/version.py b/src/botservice/azext_bot/botservice/version.py new file mode 100644 index 00000000000..fb0159ed93d --- /dev/null +++ b/src/botservice/azext_bot/botservice/version.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" diff --git a/src/botservice/azext_bot/commands.py b/src/botservice/azext_bot/commands.py new file mode 100644 index 00000000000..d0f958bb7b1 --- /dev/null +++ b/src/botservice/azext_bot/commands.py @@ -0,0 +1,44 @@ +# -------------------------------------------------------------------------------------------- +# 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.commands import CliCommandType +from azext_bot._client_factory import ( + get_botservice_management_client, + get_botChannels_client) +from azext_bot._exception_handler import bot_exception_handler + + +def load_command_table(self, _): + botOperations_commandType = CliCommandType( + operations_tmpl='azext_bot.botservice.operations.bots_operations#BotsOperations.{}', # pylint: disable=line-too-long + client_factory=get_botservice_management_client, + exception_handler=bot_exception_handler + ) + + channelOperations_commandType = CliCommandType( + operations_tmpl='azext_bot.custom#channelOperationsInstance.{}', # pylint: disable=line-too-long + client_factory=get_botChannels_client, + exception_handler=bot_exception_handler + ) + + updateBotService_commandType = CliCommandType( + operations_tmpl='azext_bot.custom#{}', + client_factory=get_botservice_management_client, + exception_handler=bot_exception_handler + ) + + with self.command_group('bot', botOperations_commandType) as g: + g.custom_command('create', 'create') + g.custom_command('publish', 'publish_app') + g.custom_command('download', 'download_app') + g.custom_command('show', 'get_bot') + g.custom_command('delete', 'delete_bot') + g.generic_update_command('update', setter_name='update', setter_type=updateBotService_commandType) + + for channel in ['facebook', 'email', 'msteams', 'skype', 'kik', 'webchat', 'directline', 'telegram', 'sms', 'slack']: + with self.command_group('bot {}'.format(channel), channelOperations_commandType) as g: + g.custom_command('create', '{}_create'.format(channel)) + g.command('show', '{}_get'.format(channel)) + g.command('delete', '{}_delete'.format(channel)) diff --git a/src/botservice/azext_bot/custom.py b/src/botservice/azext_bot/custom.py new file mode 100644 index 00000000000..ea61519dc2e --- /dev/null +++ b/src/botservice/azext_bot/custom.py @@ -0,0 +1,487 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from knack.prompting import prompt_y_n +from knack.util import CLIError +from knack.log import get_logger +from azext_bot.botservice import AzureBotService +from azext_bot.botservice.models import Bot, BotProperties, sku, BotChannel +from azure.cli.command_modules.appservice.custom import enable_zip_deploy, config_source_control, get_app_settings, _get_site_credential, _get_scm_url +from azure.cli.command_modules.resource.custom import deploy_arm_template +from azure.cli.core._profile import Profile +import json +import adal +import os +import shutil + +logger = get_logger(__name__) + + +def provisionConvergedApp(bot_name): + botfirstpartyid = 'f3723d34-6ff5-4ceb-a148-d99dcd2511fc' + aadclientid = '1950a258-227b-4e31-a9cf-717495945fc2' + tenantid = '72f988bf-86f1-41af-91ab-2d7cd011db47' + + authority = 'https://login.windows.net/{0}'.format(tenantid) + context = adal.AuthenticationContext( + authority=authority, + validate_authority=True, + api_version=None + ) + + code = context.acquire_user_code( + resource=botfirstpartyid, + client_id=aadclientid, + ) + + logger.warning(code['message']) + + token = context.acquire_token_with_device_code( + resource=botfirstpartyid, + user_code_info=code, + client_id=aadclientid + ) + access_token = token['accessToken'] + + import requests + headers = {'Authorization': 'Bearer {0}'.format(access_token)} + response = requests.post( + 'https://dev.botframework.com/api/botApp/provisionConvergedApp?name={0}'.format(bot_name), + headers=headers + ) + if response.status_code not in [201]: + raise CLIError('Unable to provision appid and password for supplied credentials') + response_content = json.loads(response.content.decode('utf-8')) + msa_app_id = response_content['AppId'] + password = response_content['Password'] + + return msa_app_id, password + + +def create(cmd, client, resource_group_name, resource_name, kind, description=None, display_name=None, + endpoint=None, msa_app_id=None, password=None, tags=None, storageAccountName=None, + location='Central US', sku_name='F0', appInsightsLocation='South Central US', bot_json=None, language='Csharp'): + display_name = display_name or resource_name + kind = kind.lower() + + if not msa_app_id: + msa_app_id, password = provisionConvergedApp(resource_name) + logger.warning('obtained msa app id and password. Provisioning bot now.') + + if kind == 'registration': + kind = 'bot' + if not endpoint or not msa_app_id: + raise CLIError('Endpoint and msa app id are required for creating a registration bot') + parameters = Bot( + location='global', + sku=sku.Sku(sku_name), + kind=kind, + properties=BotProperties( + display_name=display_name, + description=description, + endpoint=endpoint, + msa_app_id=msa_app_id, + password=password + ) + ) + return client.bots.create( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters + ) + elif kind == 'webapp' or kind == 'function': + return create_app(cmd, client, resource_group_name, resource_name, description, kind, msa_app_id, password, storageAccountName, location, sku_name, appInsightsLocation, bot_json, language) + else: + raise CLIError('Invalid Bot Parameter : Kind') + + +def update(client, parameters, resource_group_name, **kwargs): + try: + return client.bots.update( + resource_group_name=resource_group_name, + resource_name=parameters.name, + **(parameters.__dict__) + ) + except AttributeError: + return None + + +def delete_bot(client, resource_group_name, resource_name): + # temporary workaround - delete every channel first and then delete bot + for channel in ['facebook', 'email', 'msTeams', 'skype', 'kik', 'directLine', 'telegram', 'sms', 'slack']: + channelName = '{}Channel'.format(channel) + channelName = channelName[:1].upper() + channelName[1:] + client.channels.delete( + resource_group_name=resource_group_name, + resource_name=resource_name, + channel_name=channelName + ) + return client.bots.delete( + resource_group_name=resource_group_name, + resource_name=resource_name + ) + + +def create_bot_json(cmd, client, resource_group_name, resource_name, app_password=None, raw_bot_properties=None): + if not raw_bot_properties: + raw_bot_properties = client.bots.get( + resource_group_name=resource_group_name, + resource_name=resource_name + ) + if not app_password: + app_settings = get_app_settings( + cmd=cmd, + resource_group_name=resource_group_name, + name=resource_name + ) + app_password = [item['value'] for item in app_settings if item['name'] == 'MicrosoftAppPassword'][0] + + profile = Profile(cli_ctx=cmd.cli_ctx) + return { + 'type': 'abs', + 'id': raw_bot_properties.name, + 'name': raw_bot_properties.properties.display_name, + 'appId': raw_bot_properties.properties.msa_app_id, + 'appPassword': app_password, + 'endpoint': raw_bot_properties.properties.endpoint, + 'resourceGroup': str(resource_group_name), + 'tenantId': profile.get_subscription(subscription=client.config.subscription_id)['tenantId'], + 'subscriptionId': client.config.subscription_id + } + + +def get_bot(cmd, client, resource_group_name, resource_name, bot_json=None): + raw_bot_properties = client.bots.get( + resource_group_name=resource_group_name, + resource_name=resource_name + ) + if bot_json: + return create_bot_json(cmd, client, resource_group_name, resource_name, raw_bot_properties=raw_bot_properties) + + return raw_bot_properties + + +def create_app(cmd, client, resource_group_name, resource_name, description, kind, appid, password, storageAccountName, location, sku, appInsightsLocation, bot_json, language): + if kind == 'function': + template_name = 'functionapp.template.json' + if language == 'Csharp': + zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/csharp-abs-functions_emptybot.zip' + else: + zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/node.js-abs-functions_emptybot_funcpack.zip' + + else: + kind = 'sdk' + template_name = 'webapp.template.json' + if language == 'Csharp': + zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/csharp-abs-webapp_simpleechobot_precompiled.zip' + else: + zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/node.js-abs-webapp_hello-chatconnector.zip' + + create_new_storage = False + if not storageAccountName: + import re + import string + import random + create_new_storage = True + storageAccountName = re.sub(r'[^a-z0-9]', '', resource_name[:10] + ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(4))) + + paramsdict = { + "location": location, + "kind": kind, + "sku": sku, + "siteName": resource_name, + "appId": appid, + "appSecret": password, + "storageAccountResourceId": "", + "serverFarmId": "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Web/serverfarms/{2}".format(client.config.subscription_id, resource_group_name, resource_name), + "zipUrl": zip_url, + "createNewStorage": create_new_storage, + "storageAccountName": storageAccountName, + "botEnv": "prod", + "useAppInsights": True, + "appInsightsLocation": appInsightsLocation, + "createServerFarm": True, + "serverFarmLocation": location.lower().replace(' ', ''), + "azureWebJobsBotFrameworkDirectLineSecret": "", + "botId": resource_name + } + if description: + paramsdict['description'] = description + params = {k: {'value': v} for k, v in paramsdict.items()} + + dir_path = os.path.dirname(os.path.realpath(__file__)) + deploy_result = deploy_arm_template( + cmd=cmd, + resource_group_name=resource_group_name, + template_file=os.path.join(dir_path, template_name), + parameters=[[json.dumps(params)]], + deployment_name=resource_name, + mode='Incremental' + ) + + deploy_result.wait() + if bot_json: + return create_bot_json(cmd, client, resource_group_name, resource_name, app_password=password) + + +def publish_app(cmd, client, resource_group_name, resource_name, git_url=None, git_token=None, git_branch='master', code_dir=None): + # if given msbot json, use that to update environment settings like luis settings + if git_url: + return config_source_control( + cmd=cmd, + name=resource_name, + resource_group_name=resource_group_name, + repo_url=git_url, + branch=git_branch, + git_token=git_token + ) + + # since there is no git url it's definitely publish from local + if not code_dir: + code_dir = os.getcwd() + + if code_dir: + if not os.path.isdir(code_dir): + raise CLIError('Please supply a valid directory path containing your source code') + # ensure that the directory contains appropriate post deploy scripts folder + if 'PostDeployScripts' not in os.listdir(code_dir): + raise CLIError('Not a valid azure publish directory. missing post deploy scripts') + shutil.make_archive('upload', 'zip', code_dir) + output = enable_zip_deploy(cmd, resource_group_name, resource_name, 'upload.zip') + os.remove('upload.zip') + return output + + +def download_app(cmd, client, resource_group_name, resource_name, file_save_path=None): + # get the bot and ensure it's not a registration only bot + raw_bot_properties = client.bots.get( + resource_group_name=resource_group_name, + resource_name=resource_name + ) + if(raw_bot_properties.kind == 'bot'): + raise CLIError('Source download is not supported for registration only bots') + file_save_path = file_save_path or os.getcwd() + if not os.path.isdir(file_save_path): + raise CLIError('Path name not valid') + folder_path = os.path.join(file_save_path, resource_name) + if os.path.exists(folder_path): + raise CLIError('The path {0} already exists. Please delete it or specify an alternate path'.format(folder_path)) + os.mkdir(folder_path) + + user_name, password = _get_site_credential(cmd.cli_ctx, resource_group_name, resource_name, None) + scm_url = _get_scm_url(cmd, resource_group_name, resource_name, None) + + import urllib3 + authorization = urllib3.util.make_headers(basic_auth='{0}:{1}'.format(user_name, password)) + headers = authorization + headers['content-type'] = 'application/json' + + payload = { + 'command': 'PostDeployScripts\prepareSrc.cmd {0}'.format(password), + 'dir': 'site\wwwroot' + } + + import requests + response = requests.post(scm_url + '/api/command', data=json.dumps(payload), headers=headers) + if response.status_code != 200: + raise CLIError('Zip Download failed with status code {} and reason {}'.format( + response.status_code, response.text)) + response = requests.get(scm_url + '/api/vfs/site/bot-src.zip', headers=authorization) + if response.status_code != 200: + raise CLIError('Zip Download failed with status code {} and reason {}'.format( + response.status_code, response.text)) + download_path = os.path.join(file_save_path, 'download.zip') + with open(os.path.join(file_save_path, 'download.zip'), 'wb') as f: + f.write(response.content) + import zipfile + zip_ref = zipfile.ZipFile(download_path) + zip_ref.extractall(folder_path) + zip_ref.close() + os.remove(download_path) + return {'downloadPath': folder_path} + + +def create_channel(client, channel, channel_name, resource_group_name, resource_name): + botChannel = BotChannel( + location='global', + properties=channel + ) + return client.channels.create( + resource_group_name=resource_group_name, + resource_name=resource_name, + channel_name=channel_name, + parameters=botChannel + ) + + +def facebook_create(client, resource_group_name, resource_name, page_id, app_id, app_secret, access_token, is_disabled=None): + from azext_bot.botservice.models import FacebookChannel, FacebookChannelProperties, FacebookPage + channel = FacebookChannel( + properties=FacebookChannelProperties( + pages=[FacebookPage(id=page_id, access_token=access_token)], + app_id=app_id, + app_secret=app_secret, + access_token=access_token, + is_enabled=not is_disabled + ) + ) + return create_channel(client, channel, 'FacebookChannel', resource_group_name, resource_name) + + +def email_create(client, resource_group_name, resource_name, email_address, password, is_disabled=None): + from azext_bot.botservice.models import EmailChannel, EmailChannelProperties + channel = EmailChannel( + properties=EmailChannelProperties( + email_address=email_address, + password=password, + is_enabled=not is_disabled + ) + ) + return create_channel(client, channel, 'EmailChannel', resource_group_name, resource_name) + + +def msteams_create(client, resource_group_name, resource_name, is_disabled=None, enable_messaging=None, enable_media_cards=None, enable_video=None, enable_calling=None): + from azext_bot.botservice.models import MsTeamsChannel, MsTeamsChannelProperties + channel = MsTeamsChannel( + properties=MsTeamsChannelProperties( + is_enabled=not is_disabled, + enable_messaging=enable_messaging, + enable_media_cards=enable_media_cards, + enable_video=enable_video, + enable_calling=enable_calling + ) + ) + return create_channel(client, channel, 'MsTeamsChannel', resource_group_name, resource_name) + + +def skype_create(client, resource_group_name, resource_name, is_disabled=None, enable_messaging=None, enable_media_cards=None, enable_video=None, enable_calling=None, enable_screen_sharing=None, enable_groups=None, calling_web_hook=None): + from azext_bot.botservice.models import SkypeChannel, SkypeChannelProperties + channel = SkypeChannel( + properties=SkypeChannelProperties( + is_enabled=not is_disabled, + enable_messaging=enable_messaging, + enable_media_cards=enable_media_cards, + enable_video=enable_video, + enable_calling=enable_calling, + enable_screen_sharing=enable_screen_sharing, + enable_groups=enable_groups, + calling_web_hook=calling_web_hook + ) + ) + return create_channel(client, channel, 'SkypeChannel', resource_group_name, resource_name) + + +def kik_create(client, resource_group_name, resource_name, user_name, api_key, is_disabled=None, is_validated=None): + from azext_bot.botservice.models import KikChannel, KikChannelProperties + channel = KikChannel( + properties=KikChannelProperties( + user_name=user_name, + api_key=api_key, + is_enabled=not is_disabled, + is_validated=is_validated + ) + ) + return create_channel(client, channel, 'KikChannel', resource_group_name, resource_name) + + +def webchat_create(client, resource_group_name, resource_name, is_disabled=None, enable_preview=None, site_name='default'): + if not enable_preview: + enable_preview = False + from azext_bot.botservice.models import WebChatChannel, WebChatChannelProperties, WebChatSite + channel = WebChatChannel( + properties=WebChatChannelProperties( + sites=[WebChatSite( + site_name=site_name, + is_enabled=not is_disabled, + enable_preview=enable_preview, + )] + ) + ) + return create_channel(client, channel, 'WebChatChannel', resource_group_name, resource_name) + + +def directline_create(client, resource_group_name, resource_name, is_disabled=None, is_v1_disabled=None, is_v3_disabled=None, site_name='default'): + from azext_bot.botservice.models import DirectLineChannel, DirectLineChannelProperties, DirectLineSite + channel = DirectLineChannel( + properties=DirectLineChannelProperties( + sites=[DirectLineSite( + site_name=site_name, + is_enabled=not is_disabled, + is_v1_enabled=not is_v1_disabled, + is_v3_enabled=not is_v3_disabled + )] + ) + ) + return create_channel(client, channel, 'DirectLineChannel', resource_group_name, resource_name) + + +def telegram_create(client, resource_group_name, resource_name, access_token, is_disabled=None, is_validated=None): + from azext_bot.botservice.models import TelegramChannel, TelegramChannelProperties + channel = TelegramChannel( + properties=TelegramChannelProperties( + access_token=access_token, + is_enabled=not is_disabled, + is_validated=is_validated + ) + ) + return create_channel(client, channel, 'TelegramChannel', resource_group_name, resource_name) + + +def sms_create(client, resource_group_name, resource_name, phone, account_sid, auth_token, is_disabled=None, is_validated=None): + from azext_bot.botservice.models import SmsChannel, SmsChannelProperties + channel = SmsChannel( + properties=SmsChannelProperties( + phone=phone, + account_sid=account_sid, + auth_token=auth_token, + is_enabled=not is_disabled, + is_validated=is_validated + ) + ) + return create_channel(client, channel, 'SmsChannel', resource_group_name, resource_name) + + +def slack_create(client, resource_group_name, resource_name, client_id, client_secret, verification_token, is_disabled=None, landing_page_url=None): + from azext_bot.botservice.models import SlackChannel, SlackChannelProperties + channel = SlackChannel( + properties=SlackChannelProperties( + client_id=client_id, + client_secret=client_secret, + verification_token=verification_token, + landing_page_url=landing_page_url, + is_enabled=not is_disabled + ) + ) + return create_channel(client, channel, 'SlackChannel', resource_group_name, resource_name) + + +class ChannelOperations: + def __init__(self): + for channel in ['facebook', 'email', 'msTeams', 'skype', 'kik', 'webChat', 'directLine', 'telegram', 'sms', 'slack']: + channelName = '{}Channel'.format(channel) + channelName = channelName[:1].upper() + channelName[1:] + + def get_wrapper(channel_name): + def get(self, resource_group_name, resource_name): + return self.get( + resource_group_name=resource_group_name, + resource_name=resource_name, + channel_name=channel_name + ) + return get + + def delete_wrapper(channel_name): + def delete(self, resource_group_name, resource_name): + return self.delete( + resource_group_name=resource_group_name, + resource_name=resource_name, + channel_name=channel_name + ) + return delete + setattr(self, '{}_get'.format(channel.lower()), get_wrapper(channelName)) + setattr(self, '{}_delete'.format(channel.lower()), delete_wrapper(channelName)) + + +channelOperationsInstance = ChannelOperations() diff --git a/src/botservice/azext_bot/functionapp.template.json b/src/botservice/azext_bot/functionapp.template.json new file mode 100644 index 00000000000..e5e7149341f --- /dev/null +++ b/src/botservice/azext_bot/functionapp.template.json @@ -0,0 +1,437 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "botEnv": { + "type": "string", + "defaultValue": "prod" + }, + "botId": { + "type": "string" + }, + "description": { + "type": "string", + "defaultValue": "" + }, + "location": { + "type": "string" + }, + "sku": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "siteName": { + "type": "string" + }, + "createNewStorage": { + "type": "bool" + }, + "storageAccountName": { + "type": "string" + }, + "storageAccountResourceId": { + "type": "string", + "defaultValue": "" + }, + "appId": { + "type": "string", + "defaultValue": "1234" + }, + "appSecret": { + "type": "string", + "defaultValue": "blank" + }, + "azureWebJobsBotFrameworkDirectLineSecret": { + "type": "string", + "defaultValue": "" + }, + "zipUrl": { + "type": "string", + "defaultValue": "" + }, + "proactiveZipUrl": { + "type": "string", + "defaultValue": "" + }, + "useAppInsights": { + "type": "bool" + }, + "appInsightsLocation": { + "type": "string" + }, + "serverFarmId": { + "type": "string" + }, + "createServerFarm": { + "type": "bool" + }, + "serverFarmLocation": { + "type": "string", + "defaultValue": "" + }, + "serverFarmSku": { + "type": "object", + "defaultValue": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + } + }, + "endpoint": { + "type": "string", + "defaultValue": "" + }, + "luisApiLocation": { + "type": "string", + "defaultValue": "Global" + } + }, + "variables": { + "storageAccountType": "Standard_LRS", + "storageAccountId": "[if(or(parameters('createNewStorage'), equals('', parameters('storageAccountResourceId'))), resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), parameters('storageAccountResourceId'))]", + "serverFarmName": "[last(split(parameters('serverFarmId'), '/'))]", + "myWorkerSize": 0, + "proactiveFunctionName": "[concat(parameters('siteName'), '-function')]", + "insightsName": "[concat(parameters('botId'), substring(uniqueString(resourceGroup().id), 0, 6))]", + "config": { + "scratch": { + "stateEndpoint": "https://intercom-api-scratch.azurewebsites.net", + "azureWebJobsBotFrameworkDirectLineEndpoint": "https://directline.scratch.botframework.com/", + "blobStoreName": "icscratch", + "openIdMetadata": "https://intercom-api-ppe.azurewebsites.net/v1/.well-known/openidconfiguration" + }, + "ppe": { + "stateEndpoint": "https://intercom-api-ppe.azurewebsites.net", + "azureWebJobsBotFrameworkDirectLineEndpoint": "https://directline.ppe.botframework.com/", + "blobStoreName": "intercomppe", + "openIdMetadata": "https://intercom-api-ppe.azurewebsites.net/v1/.well-known/openidconfiguration" + }, + "prod": { + "stateEndpoint": "", + "azureWebJobsBotFrameworkDirectLineEndpoint": "https://directline.botframework.com/", + "blobStoreName": "connectorprod", + "openIdMetadata": "" + } + }, + "botAppKinds": { + "function": "functionapp", + "sdk": "app", + "designer": "app", + "bot": "" + }, + "botAppKind": "[variables('botAppKinds')[parameters('kind')]]", + "currentConfig": "[variables('config')[toLower(parameters('botEnv'))]]", + "siteHost": "[concat(parameters('siteName'), '.azurewebsites.net')]", + "botEndpointConfig": { + "bot": "[parameters('endpoint')]", + "sdk": "[concat('https://', variables('siteHost'), '/api/messages')]", + "designer": "[concat('https://', variables('siteHost'), '/api/messages')]", + "function": "[concat('https://', variables('siteHost'), '/api/messages?code=', 'NYI')]" + }, + "botEndpoint": "[variables('botEndpointConfig')[parameters('kind')]]", + "luisApiName": "", + "luisApiResId": "[resourceId('Microsoft.CognitiveServices/accounts/', variables('luisApiName'))]" + }, + "resources": [ + { + "name": "[if(equals('', variables('luisApiName')), 'nosuch', variables('luisApiName'))]", + "apiVersion": "2017-04-18", + "condition": "[not(equals(variables('luisApiName'), ''))]", + "type": "Microsoft.CognitiveServices/accounts", + "location": "[parameters('luisApiLocation')]", + "sku": { + "name": "F0" + }, + "kind": "LUIS", + "properties": {} + }, + { + "type": "Microsoft.Storage/storageAccounts", + "condition": "[parameters('createNewStorage')]", + "name": "[parameters('storageAccountName')]", + "apiVersion": "2015-05-01-preview", + "location": "[parameters('location')]", + "properties": { + "accountType": "[variables('storageAccountType')]" + } + }, + { + "type": "Microsoft.Web/serverfarms", + "condition": "[parameters('createServerFarm')]", + "name": "[variables('serverFarmName')]", + "apiVersion": "2016-09-01", + "location": "[parameters('serverFarmLocation')]", + "sku": "[parameters('serverFarmSku')]", + "properties": { + "name": "[variables('serverFarmName')]" + } + }, + { + "name": "[variables('insightsName')]", + "type": "microsoft.insights/components", + "kind": "web", + "apiVersion": "2014-04-01", + "condition": "[parameters('useAppInsights')]", + "location": "[parameters('appInsightsLocation')]", + "tags": { + "[concat('hidden-link:', resourceId('Microsoft.BotService/botServices/', parameters('botId')))]": "Resource", + "[concat('hidden-link:', resourceId('Microsoft.Web/sites/', parameters('siteName')))]": "Resource" + }, + "properties": { + "ApplicationId": "[parameters('botId')]" + } + }, + { + "name": "[parameters('siteName')]", + "type": "Microsoft.Web/sites", + "apiVersion": "2015-08-01", + "condition": "[not(equals(parameters('zipUrl'), ''))]", + "location": "[parameters('location')]", + "kind": "[variables('botAppKind')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", + "[parameters('serverFarmId')]" + ], + "properties": { + "name": "[parameters('siteName')]", + "serverFarmId": "[parameters('serverFarmId')]", + "siteConfig": { + "appSettings": [ + { + "name": "AzureWebJobsStorage", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "AzureWebJobsDashboard", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "WEBSITE_NODE_DEFAULT_VERSION", + "value": "6.9.1" + }, + { + "name": "BotEnv", + "value": "[parameters('botEnv')]" + }, + { + "name": "BotId", + "value": "[parameters('botId')]" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + }, + { + "name": "BotStateEndpoint", + "value": "[variables('currentConfig').stateEndpoint]" + }, + { + "name": "BotOpenIdMetadata", + "value": "[variables('currentConfig').openIdMetadata]" + }, + { + "name": "UseTableStorageForConversationState", + "value": "true" + }, + { + "name": "BotDevAppInsightsKey", + "value": "[reference(resourceId('microsoft.insights/components/', variables('insightsName')), '2015-05-01').InstrumentationKey]" + }, + { + "name": "BotDevAppInsightsName", + "value": "[variables('insightsName')]" + }, + { + "name": "BotDevAppInsightsAppId", + "value": "[reference(resourceId('microsoft.insights/components/', variables('insightsName')), '2015-05-01').AppId]" + }, + { + "name": "FUNCTIONS_EXTENSION_VERSION", + "value": "~1" + }, + { + "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "WEBSITE_CONTENTSHARE", + "value": "[parameters('siteName')]" + }, + { + "name": "AzureWebJobsBotFrameworkDirectLineSecret", + "value": "[parameters('azureWebJobsBotFrameworkDirectLineSecret')]" + }, + { + "name": "AzureWebJobsBotFrameworkDirectLineEndpoint", + "value": "[variables('currentConfig').azureWebJobsBotFrameworkDirectLineEndpoint]" + } + ], + "cors": { + "allowedOrigins": [ + "https://localhost:44300", + "https://botservice.hosting.portal.azure.net", + "https://hosting.onecloud.azure-test.net/", + "https://functions.azure.com", + "https://functions-staging.azure.com", + "https://functions-next.azure.com" + ] + } + } + }, + "resources": [ + { + "name": "MSDeploy", + "type": "Extensions", + "apiVersion": "2015-02-01", + "condition": "[not(equals(parameters('zipUrl'), ''))]", + "dependsOn": [ + "[concat('Microsoft.Web/Sites/', parameters('siteName'))]" + ], + "properties": { + "packageUri": "[parameters('zipUrl')]", + "dbType": "None", + "connectionString": "", + "setParameters": { + "IIS Web Application Name": "[parameters('siteName')]" + } + } + }, + { + "apiVersion": "2015-08-01", + "name": "logs", + "type": "config", + "dependsOn": [ + "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]", + "[resourceId('Microsoft.Web/Sites/extensions', parameters('siteName'), 'MSDeploy')]" + ], + "properties": { + "applicationLogs": { + "fileSystem": { + "level": "Error" + }, + "azureTableStorage": { + "level": "Off", + "sasUrl": null + }, + "azureBlobStorage": { + "level": "Error", + "sasUrl": null, + "retentionInDays": 1 + } + }, + "httpLogs": { + "fileSystem": { + "retentionInMb": 35, + "retentionInDays": 1, + "enabled": true + }, + "azureBlobStorage": { + + "enabled": false + } + }, + "failedRequestsTracing": { + "enabled": true + }, + "detailedErrorMessages": { + "enabled": true + } + } + } + ] + }, + { + "apiVersion": "2016-03-01", + "type": "Microsoft.Web/sites", + "condition": "[not(equals(parameters('proactiveZipUrl'), ''))]", + "name": "[variables('proactiveFunctionName')]", + "location": "[parameters('location')]", + "kind": "functionapp", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", + "[parameters('serverFarmId')]" + ], + "properties": { + "siteConfig": { + "appSettings": [ + { + "name": "AzureWebJobsDashboard", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "AzureWebJobsStorage", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "WEBSITE_CONTENTSHARE", + "value": "[toLower(variables('proactiveFunctionName'))]" + }, + { + "name": "FUNCTIONS_EXTENSION_VERSION", + "value": "~1" + }, + { + "name": "AzureWebJobsBotFrameworkDirectLineSecret", + "value": "[parameters('azureWebJobsBotFrameworkDirectLineSecret')]" + }, + { + "name": "AzureWebJobsBotFrameworkDirectLineEndpoint", + "value": "[variables('currentConfig').azureWebJobsBotFrameworkDirectLineEndpoint]" + } + ] + } + }, + "resources": [ + { + "name": "MSDeploy", + "type": "Extensions", + "apiVersion": "2015-02-01", + "condition": "[not(equals(parameters('proactiveZipUrl'), ''))]", + "dependsOn": [ + "[concat('Microsoft.Web/Sites/', variables('proactiveFunctionName'))]" + ], + "properties": { + "packageUri": "[parameters('proactiveZipUrl')]" + } + } + ] + }, + { + "apiVersion": "2017-12-01", + "type": "Microsoft.BotService/botServices", + "name": "[parameters('botId')]", + "location": "global", + "kind": "[parameters('kind')]", + "sku": { + "name": "[parameters('sku')]" + }, + "properties": { + "name": "[parameters('botId')]", + "description": "[parameters('description')]", + "displayName": "[parameters('botId')]", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "developerAppInsightsApplicationId": "[variables('insightsName')]", + "developerAppInsightKey": "[reference(resourceId('microsoft.insights/components/', variables('insightsName')), '2015-05-01').InstrumentationKey]" + }, + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", + "[parameters('serverFarmId')]", + "[resourceId('Microsoft.Web/sites/', parameters('siteName'))]", + "[resourceId('microsoft.insights/components/', variables('insightsName'))]" + ] + } + ] +} \ No newline at end of file diff --git a/src/botservice/azext_bot/webapp.template.json b/src/botservice/azext_bot/webapp.template.json new file mode 100644 index 00000000000..9db896c5ee4 --- /dev/null +++ b/src/botservice/azext_bot/webapp.template.json @@ -0,0 +1,414 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "botEnv": { + "type": "string", + "defaultValue": "prod" + }, + "botId": { + "type": "string" + }, + "description": { + "type": "string", + "defaultValue": "" + }, + "location": { + "type": "string" + }, + "sku": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "siteName": { + "type": "string" + }, + "createNewStorage": { + "type": "bool" + }, + "storageAccountName": { + "type": "string" + }, + "storageAccountResourceId": { + "type": "string", + "defaultValue": "" + }, + "appId": { + "type": "string", + "defaultValue": "1234" + }, + "appSecret": { + "type": "string", + "defaultValue": "blank" + }, + "azureWebJobsBotFrameworkDirectLineSecret": { + "type": "string", + "defaultValue": "" + }, + "zipUrl": { + "type": "string", + "defaultValue": "" + }, + "proactiveZipUrl": { + "type": "string", + "defaultValue": "" + }, + "useAppInsights": { + "type": "bool" + }, + "appInsightsLocation": { + "type": "string" + }, + "serverFarmId": { + "type": "string" + }, + "createServerFarm": { + "type": "bool" + }, + "serverFarmLocation": { + "type": "string", + "defaultValue": "" + }, + "serverFarmSku": { + "type": "object", + "defaultValue": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + } + }, + "endpoint": { + "type": "string", + "defaultValue": "" + }, + "luisApiLocation": { + "type": "string", + "defaultValue": "Global" + } + }, + "variables": { + "storageAccountType": "Standard_LRS", + "storageAccountId": "[if(or(parameters('createNewStorage'), equals('', parameters('storageAccountResourceId'))), resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), parameters('storageAccountResourceId'))]", + "serverFarmName": "[last(split(parameters('serverFarmId'), '/'))]", + "myWorkerSize": 0, + "proactiveFunctionName": "[concat(parameters('siteName'), '-function')]", + "insightsName": "[concat(parameters('botId'), substring(uniqueString(resourceGroup().id), 0, 6))]", + "config": { + "scratch": { + "stateEndpoint": "https://intercom-api-scratch.azurewebsites.net", + "azureWebJobsBotFrameworkDirectLineEndpoint": "https://directline.scratch.botframework.com/", + "blobStoreName": "icscratch", + "openIdMetadata": "https://intercom-api-ppe.azurewebsites.net/v1/.well-known/openidconfiguration" + }, + "ppe": { + "stateEndpoint": "https://intercom-api-ppe.azurewebsites.net", + "azureWebJobsBotFrameworkDirectLineEndpoint": "https://directline.ppe.botframework.com/", + "blobStoreName": "intercomppe", + "openIdMetadata": "https://intercom-api-ppe.azurewebsites.net/v1/.well-known/openidconfiguration" + }, + "prod": { + "stateEndpoint": "", + "azureWebJobsBotFrameworkDirectLineEndpoint": "https://directline.botframework.com/", + "blobStoreName": "connectorprod", + "openIdMetadata": "" + } + }, + "botAppKinds": { + "function": "functionapp", + "sdk": "app", + "designer": "app", + "bot": "" + }, + "botAppKind": "[variables('botAppKinds')[parameters('kind')]]", + "currentConfig": "[variables('config')[toLower(parameters('botEnv'))]]", + "siteHost": "[concat(parameters('siteName'), '.azurewebsites.net')]", + "botEndpointConfig": { + "bot": "[parameters('endpoint')]", + "sdk": "[concat('https://', variables('siteHost'), '/api/messages')]", + "designer": "[concat('https://', variables('siteHost'), '/api/messages')]", + "function": "[concat('https://', variables('siteHost'), '/api/messages?code=', 'NYI')]" + }, + "botEndpoint": "[variables('botEndpointConfig')[parameters('kind')]]", + "luisApiName": "", + "luisApiResId": "[resourceId('Microsoft.CognitiveServices/accounts/', variables('luisApiName'))]" + }, + "resources": [ + { + "name": "[if(equals('', variables('luisApiName')), 'nosuch', variables('luisApiName'))]", + "apiVersion": "2017-04-18", + "condition": "[not(equals(variables('luisApiName'), ''))]", + "type": "Microsoft.CognitiveServices/accounts", + "location": "[parameters('luisApiLocation')]", + "sku": { + "name": "F0" + }, + "kind": "LUIS", + "properties": {} + }, + { + "type": "Microsoft.Storage/storageAccounts", + "condition": "[parameters('createNewStorage')]", + "name": "[parameters('storageAccountName')]", + "apiVersion": "2015-05-01-preview", + "location": "[parameters('location')]", + "properties": { + "accountType": "[variables('storageAccountType')]" + } + }, + { + "type": "Microsoft.Web/serverfarms", + "condition": "[parameters('createServerFarm')]", + "name": "[variables('serverFarmName')]", + "apiVersion": "2016-09-01", + "location": "[parameters('serverFarmLocation')]", + "sku": "[parameters('serverFarmSku')]", + "properties": { + "name": "[variables('serverFarmName')]" + } + }, + { + "name": "[variables('insightsName')]", + "type": "microsoft.insights/components", + "kind": "web", + "apiVersion": "2014-04-01", + "condition": "[parameters('useAppInsights')]", + "location": "[parameters('appInsightsLocation')]", + "tags": { + "[concat('hidden-link:', resourceId('Microsoft.BotService/botServices/', parameters('botId')))]": "Resource", + "[concat('hidden-link:', resourceId('Microsoft.Web/sites/', parameters('siteName')))]": "Resource" + }, + "properties": { + "ApplicationId": "[parameters('botId')]" + } + }, + { + "name": "[parameters('siteName')]", + "type": "Microsoft.Web/sites", + "apiVersion": "2015-08-01", + "condition": "[not(equals(parameters('zipUrl'), ''))]", + "location": "[parameters('location')]", + "kind": "[variables('botAppKind')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", + "[parameters('serverFarmId')]" + ], + "properties": { + "name": "[parameters('siteName')]", + "serverFarmId": "[parameters('serverFarmId')]", + "siteConfig": { + "appSettings": [ + { + "name": "AzureWebJobsStorage", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "AzureWebJobsDashboard", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "WEBSITE_NODE_DEFAULT_VERSION", + "value": "6.9.1" + }, + { + "name": "BotEnv", + "value": "[parameters('botEnv')]" + }, + { + "name": "BotId", + "value": "[parameters('botId')]" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + }, + { + "name": "BotStateEndpoint", + "value": "[variables('currentConfig').stateEndpoint]" + }, + { + "name": "BotOpenIdMetadata", + "value": "[variables('currentConfig').openIdMetadata]" + }, + { + "name": "UseTableStorageForConversationState", + "value": "true" + }, + { + "name": "BotDevAppInsightsKey", + "value": "[reference(resourceId('microsoft.insights/components/', variables('insightsName')), '2015-05-01').InstrumentationKey]" + }, + { + "name": "BotDevAppInsightsName", + "value": "[variables('insightsName')]" + }, + { + "name": "BotDevAppInsightsAppId", + "value": "[reference(resourceId('microsoft.insights/components/', variables('insightsName')), '2015-05-01').AppId]" + } + ], + "cors": { + "allowedOrigins": [ + "https://localhost:44300", + "https://botservice.hosting.portal.azure.net", + "https://hosting.onecloud.azure-test.net/" + ] + } + } + }, + "resources": [ + { + "name": "MSDeploy", + "type": "Extensions", + "apiVersion": "2015-02-01", + "condition": "[not(equals(parameters('zipUrl'), ''))]", + "dependsOn": [ + "[concat('Microsoft.Web/Sites/', parameters('siteName'))]" + ], + "properties": { + "packageUri": "[parameters('zipUrl')]", + "dbType": "None", + "connectionString": "", + "setParameters": { + "IIS Web Application Name": "[parameters('siteName')]" + } + } + }, + { + "apiVersion": "2015-08-01", + "name": "logs", + "type": "config", + "dependsOn": [ + "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]", + "[resourceId('Microsoft.Web/Sites/extensions', parameters('siteName'), 'MSDeploy')]" + ], + "properties": { + "applicationLogs": { + "fileSystem": { + "level": "Error" + }, + "azureTableStorage": { + "level": "Off", + "sasUrl": null + }, + "azureBlobStorage": { + "level": "Error", + "sasUrl": null, + "retentionInDays": 1 + } + }, + "httpLogs": { + "fileSystem": { + "retentionInMb": 35, + "retentionInDays": 1, + "enabled": true + }, + "azureBlobStorage": { + + "enabled": false + } + }, + "failedRequestsTracing": { + "enabled": true + }, + "detailedErrorMessages": { + "enabled": true + } + } + } + ] + }, + { + "apiVersion": "2016-03-01", + "type": "Microsoft.Web/sites", + "condition": "[not(equals(parameters('proactiveZipUrl'), ''))]", + "name": "[variables('proactiveFunctionName')]", + "location": "[parameters('location')]", + "kind": "functionapp", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", + "[parameters('serverFarmId')]" + ], + "properties": { + "siteConfig": { + "appSettings": [ + { + "name": "AzureWebJobsDashboard", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "AzureWebJobsStorage", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listkeys(variables('storageAccountId'), '2015-05-01-preview').key1,';')]" + }, + { + "name": "WEBSITE_CONTENTSHARE", + "value": "[toLower(variables('proactiveFunctionName'))]" + }, + { + "name": "FUNCTIONS_EXTENSION_VERSION", + "value": "~1" + }, + { + "name": "AzureWebJobsBotFrameworkDirectLineSecret", + "value": "[parameters('azureWebJobsBotFrameworkDirectLineSecret')]" + }, + { + "name": "AzureWebJobsBotFrameworkDirectLineEndpoint", + "value": "[variables('currentConfig').azureWebJobsBotFrameworkDirectLineEndpoint]" + } + ] + } + }, + "resources": [ + { + "name": "MSDeploy", + "type": "Extensions", + "apiVersion": "2015-02-01", + "condition": "[not(equals(parameters('proactiveZipUrl'), ''))]", + "dependsOn": [ + "[concat('Microsoft.Web/Sites/', variables('proactiveFunctionName'))]" + ], + "properties": { + "packageUri": "[parameters('proactiveZipUrl')]" + } + } + ] + }, + { + "apiVersion": "2017-12-01", + "type": "Microsoft.BotService/botServices", + "name": "[parameters('botId')]", + "location": "global", + "kind": "[parameters('kind')]", + "sku": { + "name": "[parameters('sku')]" + }, + "properties": { + "name": "[parameters('botId')]", + "description": "[parameters('description')]", + "displayName": "[parameters('botId')]", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "developerAppInsightsApplicationId": "[variables('insightsName')]", + "developerAppInsightKey": "[reference(resourceId('microsoft.insights/components/', variables('insightsName')), '2015-05-01').InstrumentationKey]" + }, + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", + "[parameters('serverFarmId')]", + "[resourceId('Microsoft.Web/sites/', parameters('siteName'))]", + "[resourceId('microsoft.insights/components/', variables('insightsName'))]" + ] + } + ] +} \ No newline at end of file diff --git a/src/botservice/setup.cfg b/src/botservice/setup.cfg new file mode 100644 index 00000000000..3c6e79cf31d --- /dev/null +++ b/src/botservice/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/botservice/setup.py b/src/botservice/setup.py new file mode 100644 index 00000000000..86c46bbe21f --- /dev/null +++ b/src/botservice/setup.py @@ -0,0 +1,54 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + cmdclass = {} + +VERSION = "0.0.1" +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', +] + +DEPENDENCIES = [ +] + +with open('README.rst', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='botservice', + version=VERSION, + description='Support for Azure Bot Service 2017-12-01 preview features', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Swagat Mishra', + author_email='swagatm@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions', + classifiers=CLASSIFIERS, + packages = find_packages(exclude=["tests"]), + install_requires=DEPENDENCIES, + package_data={'azext_bot': ['azext_metadata.json']}, + include_package_data = True +) diff --git a/src/index.json b/src/index.json index fe1bf8545a1..1e5a97829f7 100644 --- a/src/index.json +++ b/src/index.json @@ -789,6 +789,40 @@ "version": "0.2.0" } } + ], + "botservice": [ + { + "filename": "botservice-0.0.1-py2.py3-none-any.whl", + "sha256Digest": "365b974deade7caf5097feb1f2e04a64d89b350dba0ef2c9f13bcc234a2598c9", + "downloadUrl": "https://icscratch.blob.core.windows.net/bot-packages/botservice-0.0.1-py2.py3-none-any.whl", + "metadata": { + "azext.minCliCoreVersion": "2.0.30", + "azext.isPreview": true, + "extensions": { + "python.details": { + "contacts": [ + { + "email": "swagatm@microsoft.com", + "name": "Swagat Mishra", + "role": "author" + } + ], + "document_names": { + "description": "DESCRIPTION.rst" + }, + "project_urls": { + "Home": "https://github.com/Azure/azure-cli-extensions" + } + } + }, + "generator": "bdist_wheel (0.30.0)", + "license": "MIT", + "metadata_version": "2.0", + "name": "botservice", + "summary": "Support for Azure Bot Service 2017-12-01 preview features", + "version": "0.0.1" + } + } ] } } \ No newline at end of file