Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1602107
merge extension code with core cli
Nov 12, 2018
f0faca3
merge extension code with core cli
Nov 12, 2018
b15d366
Az bot: first refactoring session
carlosscastro Nov 12, 2018
4674507
Az bot: add requests and adal dependencies to setup.py, add license h…
stevengum Nov 13, 2018
e8d4ca1
Az bot: minor refactoring on imports, stub verbose flag in ConvergedA…
stevengum Nov 13, 2018
93c5acd
Az bot: additional refactoring and create BotJsonFormatter, WebAppOpe…
stevengum Nov 14, 2018
a11bbdb
Az bot: additional refactoring, create azure folder, AzureRegionMappe…
stevengum Nov 14, 2018
7a6f4ec
Az bot: add BotPublishHelper, rename BotConnectionsManager to Service…
stevengum Nov 15, 2018
60b72ef
Az bot: add create v3, v4 bot webapp bot tests, additional refactorin…
stevengum Nov 19, 2018
9d2903a
Progress!
carlosscastro Nov 20, 2018
be9b622
Az bot: revert default values to v3
stevengum Nov 20, 2018
b9e750a
Az bot: add docstrings to kudu_client, remove unused get_bot()
stevengum Nov 21, 2018
e259d73
adding py-directline client and preparing tests to call it
carlosscastro Nov 24, 2018
abf7dfa
Az bot: add prepare-publish test for registration bots, fix bug in bo…
stevengum Nov 24, 2018
7dc31d9
Az bot: rename publish helper test class, add test
stevengum Nov 24, 2018
7d52e28
Directline client robustness: add retrying to increase test robustness
carlosscastro Nov 25, 2018
98c5c3d
First batch of improvement in user experience, added debug logging an…
carlosscastro Nov 26, 2018
0f50f25
Moving logger.debug to logger.info, and implementing az bot show --msbot
carlosscastro Nov 27, 2018
fb609c2
Az bot: add optional --version arg to prepare-publish
stevengum Nov 27, 2018
ce45466
Az bot: add two v4 prepare-publish tests
stevengum Nov 27, 2018
372c65f
Logger from debug to info and adding get_bot
carlosscastro Nov 27, 2018
b855ee0
Adding logging to prepare publish and create upload zip
carlosscastro Nov 27, 2018
eb93d61
File reorganization and checking in test recordings after last test p…
carlosscastro Nov 27, 2018
c7d364d
Remove resolved TODOs
carlosscastro Nov 27, 2018
4b0ab4b
Az bot: add MIA license headers and update test/tools/__init__.py
stevengum Nov 27, 2018
eb5976a
Az bot: cleanup errant __init__.py files, bump version in setup.py
stevengum Nov 27, 2018
9fb84c3
Az bot: update HISTORY.rst with notes for 0.1.2
stevengum Nov 27, 2018
3e6a85a
Fix linting issues
carlosscastro Nov 27, 2018
5975391
Linting fixes
carlosscastro Nov 27, 2018
0a5566f
Fix build verifications
carlosscastro Nov 27, 2018
c08ebe1
Adjust reference
carlosscastro Nov 27, 2018
1bc9e12
Az bot: add modules to setup.py, change reference to directline_client
stevengum Nov 27, 2018
e87984f
Az bot: address Static Check and Command Table builds errors
stevengum Nov 27, 2018
c227f30
Az bot: fix missed Static Check errors
stevengum Nov 27, 2018
bb9b0be
Az bot: update azure-cli .pyproj files and botservice MANIFEST.in to …
stevengum Nov 27, 2018
5fbbd42
Az bot: add templates/ to setup.py, reorganize tests' helper classes
stevengum Nov 27, 2018
86e3e7f
Az bot: style changes in bot_operations.py
stevengum Nov 27, 2018
7cc7393
Az bot: fix typo in DirectLineClient
stevengum Nov 28, 2018
1a04b40
Az bot: re-record tests, fix Static Check error
stevengum Nov 28, 2018
e8ed0aa
Az bot: update MANIFEST.in to UNIX-compat paths, update setup.py pack…
stevengum Nov 28, 2018
075ca94
Az bot: add MIA __init__.py to templates folder
stevengum Nov 28, 2018
652cba2
Az bot: move ModExtensionSuppress import to BotServiceComandsLoader's…
stevengum Nov 28, 2018
deb9ca2
Undo file reorg and renaming
carlosscastro Nov 28, 2018
62b460c
Add missing dependency
carlosscastro Nov 28, 2018
a552fbc
Update docs for --version.
carlosscastro Nov 28, 2018
cdb70a3
Update templates folder
carlosscastro Nov 28, 2018
dca6763
Remove duplicate test
carlosscastro Nov 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions azure-cli.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -1160,13 +1160,15 @@
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\tests\latest\recordings\test_webapp_bot.yaml" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\tests\latest\recordings\test_webchat_channel.yaml" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\webapp.template.json" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\webappv4.template.json" />
<Content Include="command_modules\azure-cli-botservice\azure_cli_botservice.egg-info\dependency_links.txt" />
<Content Include="command_modules\azure-cli-botservice\azure_cli_botservice.egg-info\PKG-INFO" />
<Content Include="command_modules\azure-cli-botservice\azure_cli_botservice.egg-info\requires.txt" />
<Content Include="command_modules\azure-cli-botservice\azure_cli_botservice.egg-info\SOURCES.txt" />
<Content Include="command_modules\azure-cli-botservice\azure_cli_botservice.egg-info\top_level.txt" />
<Content Include="command_modules\azure-cli-botservice\build\lib.linux-x86_64-2.7\azure\cli\command_modules\botservice\functionapp.template.json" />
<Content Include="command_modules\azure-cli-botservice\build\lib.linux-x86_64-2.7\azure\cli\command_modules\botservice\webapp.template.json" />
<Content Include="command_modules\azure-cli-botservice\build\lib.linux-x86_64-2.7\azure\cli\command_modules\botservice\webappv4.template.json" />
<Content Include="command_modules\azure-cli-botservice\dist\azure_cli_botservice-0.1.0-py2.py3-none-any.whl" />
<Content Include="command_modules\azure-cli-botservice\HISTORY.rst" />
<Content Include="command_modules\azure-cli-botservice\MANIFEST.in" />
Expand Down
5 changes: 3 additions & 2 deletions azure-cli2017.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@
<Content Include="command_modules\azure-cli-billing\MANIFEST.in" />
<Content Include="command_modules\azure-cli-billing\README.rst" />
<Content Include="command_modules\azure-cli-billing\setup.cfg" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\functionapp.template.json" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\bot\templates\functionapp.template.json" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\tests\latest\recordings\test_auth_setting.yaml" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\tests\latest\recordings\test_directline_channel.yaml" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\tests\latest\recordings\test_msteams_channel.yaml" />
Expand All @@ -1497,7 +1497,8 @@
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\tests\latest\recordings\test_skype_channel.yaml" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\tests\latest\recordings\test_webapp_bot.yaml" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\tests\latest\recordings\test_webchat_channel.yaml" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\webapp.template.json" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\bot\templates\webapp.template.json" />
<Content Include="command_modules\azure-cli-botservice\azure\cli\command_modules\botservice\bot\templates\webappv4.template.json" />
<Content Include="command_modules\azure-cli-botservice\HISTORY.rst" />
<Content Include="command_modules\azure-cli-botservice\MANIFEST.in" />
<Content Include="command_modules\azure-cli-botservice\README.rst" />
Expand Down
5 changes: 5 additions & 0 deletions src/command_modules/azure-cli-botservice/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.1.2
+++++
* Major refactoring
* Improvements to test coverage

0.1.1
+++++
* Minor fixes
Expand Down
5 changes: 3 additions & 2 deletions src/command_modules/azure-cli-botservice/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include *.rst
include azure\cli\command_modules\botservice\functionapp.template.json
include azure\cli\command_modules\botservice\webapp.template.json
include azure/cli/command_modules/botservice/functionapp.template.json
include azure/cli/command_modules/botservice/webapp.template.json
include azure/cli/command_modules/botservice/webappv4.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class BotServiceCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):

from azure.cli.core.commands import CliCommandType
custom_type = CliCommandType(
operations_tmpl='azure.cli.command_modules.botservice.custom#{}',
Expand All @@ -21,7 +22,7 @@ def __init__(self, cli_ctx=None):
suppress_extension=ModExtensionSuppress(
__name__,
'botservice',
'0.4.0',
'0.4.1',
reason='These commands are now in the CLI',
recommend_remove=True))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def bot_exception_handler(ex):
from msrestazure.azure_exceptions import CloudError
from msrest.exceptions import ClientRequestError # pylint: disable=import-error
if isinstance(ex, ErrorException):
message = 'an error occurred with code:{0} and message:{1}'.format(
message = 'An error occurred. {0}: {1}'.format(
ex.error.error.code,
ex.error.error.message
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

name_arg_type = CLIArgumentType(metavar='NAME', configured_default='botname', id_part='Name')

supported_languages = ['Csharp', 'Node']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not an enum in your SDK (which is another way of saying, why isn't this specified in Swagger)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is not information that flows in the swagger, but higher level information. As you may know, we offer the basic CRUD operations for bot such as Create / Update / delete / Show but also some other operations that are outside of the basic crud such as Download and Publish for downloading and publishing bots. The languages are a construct of download and publish, but crud operations don't need to know the language generally.

The other scenario where languages are known is when we create a website for the bot (bot.kind == webapp). In which case we use the language to decide which bot template to publish to the website, but again it does not interact with our arm api.

Hope that makes sense, I'm happy to elaborate further.



# pylint: disable=line-too-long,too-many-statements
def load_arguments(self, _):
Expand All @@ -30,13 +32,16 @@ def load_arguments(self, _):
c.argument('password', options_list=['-p', '--password'], help='The Microsoft account (MSA) password for the bot.')
c.argument('storageAccountName', options_list=['-s', '--storage'], help='Storage account name to be used with the bot. If not provided, a new account will be created.', arg_group='Web/Function bot Specific')
c.argument('tags', arg_type=tags_type)
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('language', help='The language to be used to create the bot.', options_list=['--lang'], arg_type=get_enum_type(supported_languages), 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-location'], arg_group='Web/Function bot Specific',
arg_type=get_enum_type(['South Central US', 'East US', 'West US 2', 'North Europe', 'West Europe', 'Southeast Asia']))
c.argument('version', options_list=['-v', '--version'], help='The Microsoft Bot Builder SDK version to be used to create the bot', arg_type=get_enum_type(['v3', 'v4']), arg_group='Web/Function bot Specific')

with self.argument_context('bot publish') as c:
c.argument('code_dir', options_list=['--code-dir'], help='The directory to upload bot code from.')
c.argument('proj_name', help='Name of the start up project file name.')
c.argument('version', options_list=['-v', '--version'],
help='The Microsoft Bot Builder SDK version by the bot.')

with self.argument_context('bot download') as c:
c.argument('file_save_path', options_list=['--save-path'], help='The directory to download bot code to.')
Expand All @@ -48,6 +53,9 @@ def load_arguments(self, _):
c.argument('proj_name', help='Name of the start up project file name. Required only for C#.')
c.argument('sln_name', help='Name of the start up solution file name. Required only for C#.')
c.argument('code_dir', options_list=['--code-dir'], help='The directory to download deployment scripts to.')
c.argument('version', options_list=['-v', '--version'], help='The Microsoft Bot Builder SDK version to be used '
'in the bot template that will be created.',
arg_type=get_enum_type(['v3', 'v4']), arg_group='Web/Function bot Specific')

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')
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import adal
from knack.log import get_logger

logger = get_logger(__name__)


class AdalAuthenticator: # pylint:disable=too-few-public-methods

bot_first_party_app_id = 'f3723d34-6ff5-4ceb-a148-d99dcd2511fc'
aad_client_id = '1950a258-227b-4e31-a9cf-717495945fc2'
login_url = 'https://login.windows.net/common'

@staticmethod
def acquire_token():

# Create ADAL Authentication Context to acquire tokens
context = adal.AuthenticationContext(
authority=AdalAuthenticator.login_url,
validate_authority=True,
api_version=None
)

# Acquire a device code
code = context.acquire_user_code(
resource=AdalAuthenticator.bot_first_party_app_id,
client_id=AdalAuthenticator.aad_client_id,
)

# Request the user to perform device login
logger.warning(code['message'])

# Use the device code to retrieve a token
token = context.acquire_token_with_device_code(
resource=AdalAuthenticator.bot_first_party_app_id,
user_code_info=code,
client_id=AdalAuthenticator.aad_client_id
)

# Return the entire token object including the access token plus expiration date and other info
return token
Original file line number Diff line number Diff line change
@@ -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 knack.log import get_logger

logger = get_logger(__name__)


class AzureRegionMapper: # pylint:disable=too-few-public-methods

@staticmethod
def get_app_insights_location(key):
region_map = {
'australiaeast': 'southeastasia',
'australiacentral': 'southeastasia',
'australiacentral2': 'southeastasia',
'australiasoutheast': 'southeastasia',
'eastasia': 'southeastasia',
'southeastasia': 'westus',
'eastus': 'eastus',
'eastus2': 'eastus',
'southcentralus': 'southcentralus',
'westcentralus': 'westus2',
'westus': 'westus2',
'westus2': 'westus2',
'brazilsouth': 'southcentralus',
'centralus': 'southcentralus',
'northcentralus': 'southcentralus',
'japanwest': 'southeastasia',
'japaneast': 'southeastasia',
'southindia': 'southeastasia',
'centralindia': 'southeastasia',
'westindia': 'southeastasia',
'canadacentral': 'southcentralus',
'canadaeast': 'eastus',
'koreacentral': 'southeastasia',
'koreasouth': 'southeastasia',
'northeurope': 'northeurope',
'westeurope': 'westeurope',
'uksouth': 'westeurope',
'ukwest': 'westeurope',
'francecentral': 'westeurope',
'francesouth': 'westeurope'
}
region = region_map.get(key)

if not region:
logger.warning('Warning: provided region ("%s") for Application Insights does not exist. Defaulting to '
'"southcentralus"', key)
region = 'southcentralus'

return region
Loading