From 1e026ee4f004cb38dcf713698a2d1736e2a970a3 Mon Sep 17 00:00:00 2001 From: Ray Xi Date: Tue, 7 Mar 2017 18:22:21 -0800 Subject: [PATCH 01/15] initial update --- azure-cli.pyproj | 22 ++++++++ .../azure/__init__.py | 6 +++ .../azure/cli/__init__.py | 6 +++ .../azure/cli/command_modules/__init__.py | 6 +++ .../cognitiveservices/__init__.py | 10 ++++ .../cognitiveservices/_client_factory.py | 11 ++++ .../cognitiveservices/_params.py | 27 ++++++++++ .../cognitiveservices/commands.py | 25 ++++++++++ .../cognitiveservices/custom.py | 20 ++++++++ .../azure-cli-cognitiveservices/setup.py | 50 +++++++++++++++++++ 10 files changed, 183 insertions(+) create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/__init__.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/cli/__init__.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/__init__.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/setup.py diff --git a/azure-cli.pyproj b/azure-cli.pyproj index cadb46c8fae..f61e52a7680 100644 --- a/azure-cli.pyproj +++ b/azure-cli.pyproj @@ -158,6 +158,23 @@ + + Code + + + Code + + + Code + + + Code + + + + + + Code @@ -635,6 +652,11 @@ + + + + + diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/__init__.py new file mode 100644 index 00000000000..73baee1e640 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +import pkg_resources +pkg_resources.declare_namespace(__name__) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/__init__.py new file mode 100644 index 00000000000..73baee1e640 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +import pkg_resources +pkg_resources.declare_namespace(__name__) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/__init__.py new file mode 100644 index 00000000000..73baee1e640 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +import pkg_resources +pkg_resources.declare_namespace(__name__) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py new file mode 100644 index 00000000000..173f850d169 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +def load_params(command): + import azure.cli.command_modules.cognitiveservices._params + +def load_commands(): + import azure.cli.command_modules.cognitiveservices.commands \ No newline at end of file diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py new file mode 100644 index 00000000000..643e2d4161a --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +def cognitiveservices_client_factory(_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + return get_mgmt_service_client(CognitiveServicesManagementClient).cognitive_services_accounts + + diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py new file mode 100644 index 00000000000..fa3d7d32731 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +import os +import platform +from azure.mgmt.cognitiveservices.models import SkuName + +from azure.cli.core.commands import register_cli_argument, CliArgumentType, register_extra_cli_argument +from azure.cli.core.commands.parameters import ( + enum_choice_list, + file_type, + resource_group_name_type, + get_one_of_subscription_locations, + get_resource_name_completion_list) + + + +name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME') + +register_cli_argument('cognitiveservices', 'account_name', arg_type=name_arg_type, help='cognitive service account name', completer=get_resource_name_completion_list('Microsoft.CognitiveServices/accounts')) +register_cli_argument('cognitiveservices', 'resource_group_name', arg_type=resource_group_name_type) +register_cli_argument('cognitiveservices', 'sku_name', options_list=('--sku',), help='the Sku of cognitive services account') + + diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py new file mode 100644 index 00000000000..5c97ddd270e --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long + +from azure.cli.core.commands import cli_command + +from azure.cli.command_modules.cognitiveservices._client_factory import cognitiveservices_client_factory + +mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#CognitiveServicesAccountsOperations.' +custom_path = 'azure.cli.command_modules.cognitiveservices.custom#' + +cli_command(__name__, 'cognitiveservices account create', custom_path + 'create', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices account delete', mgmt_path + 'delete', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices account show', mgmt_path + 'get_properties', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices account list', custom_path + 'list', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices account update', mgmt_path + 'update', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices account keys regenerate', mgmt_path + 'regenerate_key', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices account keys list', mgmt_path + 'list_keys', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices account list-skus', mgmt_path + 'list_skus', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices list-skus', mgmt_path + 'list_skus', cognitiveservices_client_factory) + + diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py new file mode 100644 index 00000000000..547f870a0dd --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py @@ -0,0 +1,20 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +from azure.mgmt.cognitiveservices.models import CognitiveServicesAccountCreateParameters, Sku, SkuName + + +def list(client, resource_group_name=None): + if resource_group_name: + return client.list_by_resource_group(resource_group_name) + else: + return client.list() + +def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None): + sku = Sku(sku_name) + properties= {} + params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags) + return client.create(resource_group_name, account_name, params) + + \ No newline at end of file diff --git a/src/command_modules/azure-cli-cognitiveservices/setup.py b/src/command_modules/azure-cli-cognitiveservices/setup.py new file mode 100644 index 00000000000..f3cd6112e20 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/setup.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# -------------------------------------------------------------------------------------------- +# 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 + +# 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() + +setup( + name='azure-cli-cognitiveservices', + version='1.0.0', + description='Microsoft Azure Command-Line Tools Cognitive Services Command Module', + long_description=README, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/azure/azure-cli', + classifiers=CLASSIFIERS, + namespace_packages = [ + 'azure', + 'azure.cli', + 'azure.cli.command_modules', + ], + packages=[ + 'azure.cli.command_modules.cognitiveservices', + ], + install_requires=DEPENDENCIES, +) From b5b14bfb6b445600fd012e38933fa92bd0137b22 Mon Sep 17 00:00:00 2001 From: kostenray Date: Tue, 7 Mar 2017 18:34:54 -0800 Subject: [PATCH 02/15] update --- src/command_modules/azure-cli-cognitiveservices/README.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/command_modules/azure-cli-cognitiveservices/README.rst diff --git a/src/command_modules/azure-cli-cognitiveservices/README.rst b/src/command_modules/azure-cli-cognitiveservices/README.rst new file mode 100644 index 00000000000..72952fff618 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/README.rst @@ -0,0 +1,3 @@ +Microsoft Azure CLI 'example' Command Module +================================== + From 1a77bb57266784a67db19bd8de2e2376448e6136 Mon Sep 17 00:00:00 2001 From: kostenray Date: Mon, 24 Apr 2017 12:36:24 -0700 Subject: [PATCH 03/15] add the CLI for 2017-04-18 swagger file --- .../azure/cli/command_modules/cognitiveservices/commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py index 5c97ddd270e..c08384e0f8f 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py @@ -11,6 +11,7 @@ mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#CognitiveServicesAccountsOperations.' custom_path = 'azure.cli.command_modules.cognitiveservices.custom#' +skuavailabilitypath = 'azure.mgmt.cognitiveservices.operations.check_sku_availability_operations#CheckSkuAvailabilityOperations.' cli_command(__name__, 'cognitiveservices account create', custom_path + 'create', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account delete', mgmt_path + 'delete', cognitiveservices_client_factory) @@ -20,6 +21,6 @@ cli_command(__name__, 'cognitiveservices account keys regenerate', mgmt_path + 'regenerate_key', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account keys list', mgmt_path + 'list_keys', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account list-skus', mgmt_path + 'list_skus', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices list-skus', mgmt_path + 'list_skus', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices checkskuavailability', skuavailabilitypath + 'list', cognitiveservices_client_factory) From 96f6eb0a13f944633cd4de306827dafa4c005717 Mon Sep 17 00:00:00 2001 From: kostenray Date: Wed, 26 Apr 2017 22:46:23 -0700 Subject: [PATCH 04/15] cognitive service cli - inital version' --- azure-cli.pyproj | 7 + .../azure/cli/testsdk/base.py | 2 +- .../cognitiveservices/__init__.py | 4 +- .../cognitiveservices/_client_factory.py | 7 +- .../cognitiveservices/_help.py | 72 +++++ .../cognitiveservices/_params.py | 8 + .../cognitiveservices/commands.py | 11 +- .../cognitiveservices/custom.py | 30 ++- .../recordings/test_cognitiveservices.yaml | 247 ++++++++++++++++++ .../tests/test_cognitiveservices_command.py | 70 +++++ 10 files changed, 447 insertions(+), 11 deletions(-) create mode 100644 src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py create mode 100644 src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml create mode 100644 src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py diff --git a/azure-cli.pyproj b/azure-cli.pyproj index f61e52a7680..f8513b1f0f0 100644 --- a/azure-cli.pyproj +++ b/azure-cli.pyproj @@ -167,6 +167,9 @@ Code + + Code + Code @@ -175,6 +178,9 @@ + + Code + Code @@ -657,6 +663,7 @@ + diff --git a/src/azure-cli-testsdk/azure/cli/testsdk/base.py b/src/azure-cli-testsdk/azure/cli/testsdk/base.py index cb9fc460203..075d22241e9 100644 --- a/src/azure-cli-testsdk/azure/cli/testsdk/base.py +++ b/src/azure-cli-testsdk/azure/cli/testsdk/base.py @@ -31,7 +31,7 @@ class IntegrationTestBase(unittest.TestCase): def __init__(self, method_name): super(IntegrationTestBase, self).__init__(method_name) - self.diagnose = os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' + self.diagnose = True # os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' def cmd(self, command, checks=None, expect_failure=False): if self.diagnose: diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py index 173f850d169..691b2d5297c 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py @@ -2,9 +2,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +import azure.cli.command_modules.cognitiveservices._help # pylint: disable=unused-import def load_params(command): import azure.cli.command_modules.cognitiveservices._params def load_commands(): - import azure.cli.command_modules.cognitiveservices.commands \ No newline at end of file + import azure.cli.command_modules.cognitiveservices.commands + diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py index 643e2d4161a..63867fe4305 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py @@ -6,6 +6,9 @@ def cognitiveservices_client_factory(_): from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient - return get_mgmt_service_client(CognitiveServicesManagementClient).cognitive_services_accounts - + return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused').cognitive_services_accounts +def cognitiveservices_account_client_factory(_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused').accounts diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py new file mode 100644 index 00000000000..e9d0cb2e2f3 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py @@ -0,0 +1,72 @@ +# -------------------------------------------------------------------------------------------- +# 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.help_files import helps + +helps['cognitiveservices list'] = """ + type: command + short-summary: list all the existing cognitive services accounts under a resource group or current azure subscription + examples: + - name: list all the cognitive services accounts in a resource group + text: az cognitiveservices list -g MyResourceGroup +""" + +#helps['cognitiveservices checkskuavailability'] = """ +# type: command +# short-summary: check the available skus +#""" + +helps['cognitiveservices account'] = """ + type: group + short-summary: Manage and update cognitive services accounts + +""" + +helps['cognitiveservices account delete'] = """ + type: command + short-summary: Remove a cognitive services account. +""" + +helps['cognitiveservices account create'] = """ + type: command + short-summary: Create a cognitive services account. + examples: + - name: create a cognitive services accounts with all required fields + text: az cognitiveservices create -n myresource -g myResouceGroup --Kind myAPI --Sku S0 -l WestUs +""" + +helps['cognitiveservices account show'] = """ + type: command + short-summary: Get the details of a cognitive services account. +""" + +helps['cognitiveservices account update'] = """ + type: command + short-summary: Update the properties of a cognitive services account. +""" + +helps['cognitiveservices account list-skus'] = """ + type: command + short-summary: List the avaiable skus of a cognitive services account. +""" + + +helps['cognitiveservices account keys'] = """ + type: group + short-summary: Manage the keys of a cognitive services account. +""" + +helps['cognitiveservices account keys regenerate'] = """ + type: command + short-summary: Regenerate the keys of a cognitive services account. +""" + +helps['cognitiveservices account keys list'] = """ + type: command + short-summary: List the keys of a cognitive services account. +""" + + + diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py index fa3d7d32731..08b5812371e 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py @@ -12,6 +12,7 @@ from azure.cli.core.commands.parameters import ( enum_choice_list, file_type, + tags_type, resource_group_name_type, get_one_of_subscription_locations, get_resource_name_completion_list) @@ -23,5 +24,12 @@ register_cli_argument('cognitiveservices', 'account_name', arg_type=name_arg_type, help='cognitive service account name', completer=get_resource_name_completion_list('Microsoft.CognitiveServices/accounts')) register_cli_argument('cognitiveservices', 'resource_group_name', arg_type=resource_group_name_type) register_cli_argument('cognitiveservices', 'sku_name', options_list=('--sku',), help='the Sku of cognitive services account') +register_cli_argument('cognitiveservices', 'kind', help='the API name of cognitive services account') +register_cli_argument('cognitiveservices', 'tags', tags_type) +register_cli_argument('cognitiveservices', 'key_name', required=True, help='Key name to generate', choices=['key1', 'key2']) +register_cli_argument('cognitiveservices', 'yes', action='store_true', help='Do not prompt for confirmation') + + + diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py index c08384e0f8f..769ad447ce8 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py @@ -7,20 +7,21 @@ from azure.cli.core.commands import cli_command -from azure.cli.command_modules.cognitiveservices._client_factory import cognitiveservices_client_factory +from azure.cli.command_modules.cognitiveservices._client_factory import cognitiveservices_client_factory, cognitiveservices_account_client_factory mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#CognitiveServicesAccountsOperations.' custom_path = 'azure.cli.command_modules.cognitiveservices.custom#' -skuavailabilitypath = 'azure.mgmt.cognitiveservices.operations.check_sku_availability_operations#CheckSkuAvailabilityOperations.' + +terms = 'Microsoft may use data you send to the Cognitive Services to improve Microsoft products and services. For example we may use content that you provide to the Cognitive Services to improve our underlying algorithms and models over time. Where you send personal data to the Cognitive Services, you are responsible for obtaining sufficient consent from the data subjects. The General Privacy and Security Terms in the Online Services Terms (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) do not apply to the Cognitive Services. You must comply with use and display requirements for the Bing Search APIs. \nPlease refer to the Microsoft Cognitive Services section in the Online Services Terms for details.' cli_command(__name__, 'cognitiveservices account create', custom_path + 'create', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account delete', mgmt_path + 'delete', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account show', mgmt_path + 'get_properties', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices account list', custom_path + 'list', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices account update', mgmt_path + 'update', cognitiveservices_client_factory) +cli_command(__name__, 'cognitiveservices list', custom_path + 'list', cognitiveservices_account_client_factory) +cli_command(__name__, 'cognitiveservices account update', custom_path + 'update', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account keys regenerate', mgmt_path + 'regenerate_key', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account keys list', mgmt_path + 'list_keys', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account list-skus', mgmt_path + 'list_skus', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices checkskuavailability', skuavailabilitypath + 'list', cognitiveservices_client_factory) +#cli_command(__name__, 'cognitiveservices checkskuavailability', custom_path + 'checkskuavailability') diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py index 547f870a0dd..728665bd11f 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py @@ -2,7 +2,12 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.mgmt.cognitiveservices.models import CognitiveServicesAccountCreateParameters, Sku, SkuName +from azure.mgmt.cognitiveservices.models import CognitiveServicesAccountCreateParameters, Sku, SkuName, CognitiveServicesAccountUpdateParameters +from azure.cli.core.prompting import prompt_y_n, NoTTYException +from azure.cli.core.util import CLIError + +import azure.cli.core.azlogging as azlogging +logger = azlogging.get_az_logger(__name__) def list(client, resource_group_name=None): @@ -11,10 +16,31 @@ def list(client, resource_group_name=None): else: return client.list() -def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None): +def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None, **kwargs): + + terms = 'Notice\nMicrosoft may use data you send to the Cognitive Services to improve Microsoft products and services. For example we may use content that you provide to the Cognitive Services to improve our underlying algorithms and models over time. Where you send personal data to the Cognitive Services, you are responsible for obtaining sufficient consent from the data subjects. The General Privacy and Security Terms in the Online Services Terms (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) do not apply to the Cognitive Services. You must comply with use and display requirements for the Bing Search APIs. \n\nPlease refer to the Microsoft Cognitive Services section in the Online Services Terms for details.' + hint= '\nPlease select' + if yes: + logger.warning(terms) + else: + option = prompt_y_n(terms + hint) + if(not option): + raise CLIError('Operation cancelled.') sku = Sku(sku_name) properties= {} params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags) return client.create(resource_group_name, account_name, params) +def update(client, resource_group_name, account_name, sku_name=None, tags=None, **kwargs): + sku = Sku(sku_name) + return client.update(resource_group_name, account_name, sku, tags) + +def checkskuavailability(location=None, sku_name=None, kind=None, type=None): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + checkskuclient = get_mgmt_service_client(CognitiveServicesManagementClient, location=location).check_sku_availability + sku = [] + sku.append(Sku(sku_name)) + return checkskuclient.list(sku, kind, type) + \ No newline at end of file diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml new file mode 100644 index 00000000000..fc8f0ff7a1b --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml @@ -0,0 +1,247 @@ +interactions: +- request: + body: '{"location": "westus", "tags": {"use": "az-test"}}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [group create] + Connection: [keep-alive] + Content-Length: ['50'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 resourcemanagementclient/1.0.0rc1 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2016-09-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001","name":"clitest.rg000001","location":"westus","tags":{"use":"az-test"},"properties":{"provisioningState":"Succeeded"}}'} + headers: + cache-control: [no-cache] + content-length: ['326'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 26 Apr 2017 22:28:34 GMT'] + expires: ['-1'] + pragma: [no-cache] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-ms-ratelimit-remaining-subscription-writes: ['1194'] + status: {code: 201, message: Created} +- request: + body: '{"sku": {"name": "S0"}, "kind": "Face", "location": "westeurope", "properties": + {}}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [cognitiveservices account create] + Connection: [keep-alive] + Content-Length: ['83'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"00000629-0000-0000-0000-59011f150000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"27ec2778887649f28ebd3debd4aebfd2","dateCreated":"2017-04-26T22:28:38.586638Z","provisioningState":"Succeeded"}}'} + headers: + cache-control: [no-cache] + content-length: ['595'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 26 Apr 2017 22:28:37 GMT'] + etag: ['"00000629-0000-0000-0000-59011f150000"'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-IIS/8.5] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-aspnet-version: [4.0.30319] + x-ms-ratelimit-remaining-subscription-writes: ['1197'] + x-powered-by: [ASP.NET] + status: {code: 201, message: Created} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [cognitiveservices account show] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"00000629-0000-0000-0000-59011f150000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"27ec2778887649f28ebd3debd4aebfd2","dateCreated":"2017-04-26T22:28:38.586638Z","provisioningState":"Succeeded"}}'} + headers: + cache-control: [no-cache] + content-length: ['595'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 26 Apr 2017 22:28:38 GMT'] + etag: ['"00000629-0000-0000-0000-59011f150000"'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-IIS/8.5] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-aspnet-version: [4.0.30319] + x-powered-by: [ASP.NET] + status: {code: 200, message: OK} +- request: + body: 'b''b\''{"sku": {"name": "S0"}, "tags": {"tagname000003": "tagvalue000004"}}\''''' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [cognitiveservices account update] + Connection: [keep-alive] + Content-Length: ['61'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: PATCH + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00000829-0000-0000-0000-59011f180000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"27ec2778887649f28ebd3debd4aebfd2","dateCreated":"2017-04-26T22:28:38.586638Z"}}'} + headers: + cache-control: [no-cache] + content-length: ['630'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 26 Apr 2017 22:28:41 GMT'] + etag: ['"00000829-0000-0000-0000-59011f180000"'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-IIS/8.5] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-aspnet-version: [4.0.30319] + x-ms-ratelimit-remaining-subscription-writes: ['1191'] + x-powered-by: [ASP.NET] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [cognitiveservices account keys list] + Connection: [keep-alive] + Content-Length: ['0'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/listKeys?api-version=2017-04-18 + response: + body: {string: '{"key1":"308d345d568c491ab80e8f056070e2ef","key2":"957b9bcbd4884bd68226a03179f79b22"}'} + headers: + cache-control: [no-cache] + content-length: ['85'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 26 Apr 2017 22:28:42 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-IIS/8.5] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-aspnet-version: [4.0.30319] + x-ms-ratelimit-remaining-subscription-writes: ['1197'] + x-powered-by: [ASP.NET] + status: {code: 200, message: OK} +- request: + body: '{"keyName": "Key1"}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [cognitiveservices account keys regenerate] + Connection: [keep-alive] + Content-Length: ['19'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/regenerateKey?api-version=2017-04-18 + response: + body: {string: '{"key1":"cd2218fd4cef480ea7847b086410bd29","key2":"957b9bcbd4884bd68226a03179f79b22"}'} + headers: + cache-control: [no-cache] + content-length: ['85'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 26 Apr 2017 22:28:44 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-IIS/8.5] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-aspnet-version: [4.0.30319] + x-ms-ratelimit-remaining-subscription-writes: ['1198'] + x-powered-by: [ASP.NET] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [cognitiveservices list] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts?api-version=2017-04-18 + response: + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00000c29-0000-0000-0000-59011f1c0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"27ec2778887649f28ebd3debd4aebfd2","dateCreated":"2017-04-26T22:28:38.586638Z"}}]}'} + headers: + cache-control: [no-cache] + content-length: ['642'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 26 Apr 2017 22:28:46 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-IIS/8.5] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-aspnet-version: [4.0.30319] + x-powered-by: [ASP.NET] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [group delete] + Connection: [keep-alive] + Content-Length: ['0'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 resourcemanagementclient/1.0.0rc1 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2016-09-01 + response: + body: {string: ''} + headers: + cache-control: [no-cache] + content-length: ['0'] + date: ['Wed, 26 Apr 2017 22:28:46 GMT'] + expires: ['-1'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkc4NEEyMkRFOTYyRTBCNDgxOUJCODA2ODMxNUJGMzk2Mjg4Mnw1RUZEM0E2NDMyRDg0RjU3LVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] + pragma: [no-cache] + retry-after: ['15'] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-ms-ratelimit-remaining-subscription-writes: ['1197'] + status: {code: 202, message: Accepted} +version: 1 diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py new file mode 100644 index 00000000000..9d0070f48c8 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py @@ -0,0 +1,70 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +#pylint: disable=method-hidden +#pylint: disable=line-too-long +#pylint: disable=bad-continuation +#from _future_ import print_function + +import os +import time +import unittest + +from azure.cli.testsdk import ScenarioTest, JMESPathCheck, ResourceGroupPreparer +from azure.cli.core.util import CLIError + +class CognitiveServicesTests(ScenarioTest): + @ResourceGroupPreparer() + + def test_cognitiveservices(self, resource_group): + sname = self.create_random_name(prefix='cog', length=12) + resource_location = 'westeurope' + + #test to create cognitive services account + self.cmd('az cognitiveservices account create -n {} -g {} --kind {} --sku {} -l {} --yes'.format( + sname, resource_group, 'Face', 'S0', resource_location), checks=[ + JMESPathCheck('name', sname), + JMESPathCheck('location', resource_location), + JMESPathCheck('sku.name', 'S0'), + JMESPathCheck('provisioningState', 'Succeeded')]) + + #test to show the details of cognitive services account + self.cmd('az cognitiveservices account show -n {} -g {}'.format( + sname, resource_group), checks=[ + JMESPathCheck('name', sname), + JMESPathCheck('resourceGroup', resource_group)]) + + ##test to update the properties of cognitive servcies account + tagname = self.create_random_name(prefix='tagname', length=10) + tagvalue= self.create_random_name(prefix='tagvalue', length =10) + self.cmd('az cognitiveservices account update -n {} -g {} --sku {} --tags {}'.format( + sname, resource_group, 'S0', tagname + '=' + tagvalue), checks=[ + JMESPathCheck('sku.name', 'S0'), + JMESPathCheck('tags', {tagname:tagvalue})]) + + ##test to list keys of a cogntive services account + oldkeys = self.cmd('az cognitiveservices account keys list -n {} -g {}'.format( + sname, resource_group), checks=[ + JMESPathCheck('length(key1)', 32), + JMESPathCheck('length(key2)', 32)]).get_output_in_json() + + #test to regenerate the keys of a cognitive services account + newkeys = self.cmd('az cognitiveservices account keys regenerate -n {} -g {} --key-name key1'.format( + sname, resource_group)).get_output_in_json() + assert oldkeys != newkeys + + #test to list cognitive service accounts under current resource group + resourceResult = self.cmd('az cognitiveservices list -g {}'.format(resource_group)).get_output_in_json() + JMESPathCheck(contains(resourceResult, sname), True) + + #test to delete the cognitive services account + exitcode= self.cmd('az cognitiveservices account delete -n {} -g {}'.format( + sname, resource_group)).exit_code + assert exitcode == 0 + + + +if __name__ == '__main__': + unittest.main() From 7806815dd7147b2c8d4a6bd957708dcbbc387a0a Mon Sep 17 00:00:00 2001 From: kostenray Date: Thu, 27 Apr 2017 00:00:52 -0700 Subject: [PATCH 05/15] rollback debug code change --- src/azure-cli-testsdk/azure/cli/testsdk/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli-testsdk/azure/cli/testsdk/base.py b/src/azure-cli-testsdk/azure/cli/testsdk/base.py index 075d22241e9..cb9fc460203 100644 --- a/src/azure-cli-testsdk/azure/cli/testsdk/base.py +++ b/src/azure-cli-testsdk/azure/cli/testsdk/base.py @@ -31,7 +31,7 @@ class IntegrationTestBase(unittest.TestCase): def __init__(self, method_name): super(IntegrationTestBase, self).__init__(method_name) - self.diagnose = True # os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' + self.diagnose = os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' def cmd(self, command, checks=None, expect_failure=False): if self.diagnose: From a0763a60fa3dcfc419ff88fb559e1b17c95c3cae Mon Sep 17 00:00:00 2001 From: kostenray Date: Thu, 27 Apr 2017 11:06:40 -0700 Subject: [PATCH 06/15] style refactoring update --- .../azure/cli/testsdk/base.py | 2 +- .../cognitiveservices/_help.py | 4 +- .../cognitiveservices/_params.py | 4 +- .../cognitiveservices/commands.py | 3 - .../cognitiveservices/custom.py | 7 -- .../recordings/test_cognitiveservices.yaml | 85 +++++++++++++------ .../tests/test_cognitiveservices_command.py | 4 +- 7 files changed, 63 insertions(+), 46 deletions(-) diff --git a/src/azure-cli-testsdk/azure/cli/testsdk/base.py b/src/azure-cli-testsdk/azure/cli/testsdk/base.py index cb9fc460203..744919f3868 100644 --- a/src/azure-cli-testsdk/azure/cli/testsdk/base.py +++ b/src/azure-cli-testsdk/azure/cli/testsdk/base.py @@ -31,7 +31,7 @@ class IntegrationTestBase(unittest.TestCase): def __init__(self, method_name): super(IntegrationTestBase, self).__init__(method_name) - self.diagnose = os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' + self.diagnose = True #os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' def cmd(self, command, checks=None, expect_failure=False): if self.diagnose: diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py index e9d0cb2e2f3..0520c4ca5a1 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py @@ -33,8 +33,8 @@ type: command short-summary: Create a cognitive services account. examples: - - name: create a cognitive services accounts with all required fields - text: az cognitiveservices create -n myresource -g myResouceGroup --Kind myAPI --Sku S0 -l WestUs + - name: create a S0 face Api cognitive services accounts in West Europe without confirmation required + text: az cognitiveservices create -n myresource -g myResrouceGroup --Kind Face --Sku S0 -l WestEurope --yes """ helps['cognitiveservices account show'] = """ diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py index 08b5812371e..8be5e5e3a58 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py @@ -17,8 +17,6 @@ get_one_of_subscription_locations, get_resource_name_completion_list) - - name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME') register_cli_argument('cognitiveservices', 'account_name', arg_type=name_arg_type, help='cognitive service account name', completer=get_resource_name_completion_list('Microsoft.CognitiveServices/accounts')) @@ -27,7 +25,7 @@ register_cli_argument('cognitiveservices', 'kind', help='the API name of cognitive services account') register_cli_argument('cognitiveservices', 'tags', tags_type) register_cli_argument('cognitiveservices', 'key_name', required=True, help='Key name to generate', choices=['key1', 'key2']) -register_cli_argument('cognitiveservices', 'yes', action='store_true', help='Do not prompt for confirmation') +register_cli_argument('cognitiveservices account create', 'yes', action='store_true', help='Do not prompt for terms confirmation') diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py index 769ad447ce8..e6b43418104 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py @@ -12,8 +12,6 @@ mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#CognitiveServicesAccountsOperations.' custom_path = 'azure.cli.command_modules.cognitiveservices.custom#' -terms = 'Microsoft may use data you send to the Cognitive Services to improve Microsoft products and services. For example we may use content that you provide to the Cognitive Services to improve our underlying algorithms and models over time. Where you send personal data to the Cognitive Services, you are responsible for obtaining sufficient consent from the data subjects. The General Privacy and Security Terms in the Online Services Terms (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) do not apply to the Cognitive Services. You must comply with use and display requirements for the Bing Search APIs. \nPlease refer to the Microsoft Cognitive Services section in the Online Services Terms for details.' - cli_command(__name__, 'cognitiveservices account create', custom_path + 'create', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account delete', mgmt_path + 'delete', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account show', mgmt_path + 'get_properties', cognitiveservices_client_factory) @@ -22,6 +20,5 @@ cli_command(__name__, 'cognitiveservices account keys regenerate', mgmt_path + 'regenerate_key', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account keys list', mgmt_path + 'list_keys', cognitiveservices_client_factory) cli_command(__name__, 'cognitiveservices account list-skus', mgmt_path + 'list_skus', cognitiveservices_client_factory) -#cli_command(__name__, 'cognitiveservices checkskuavailability', custom_path + 'checkskuavailability') diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py index 728665bd11f..08fc7ed56a0 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py @@ -35,12 +35,5 @@ def update(client, resource_group_name, account_name, sku_name=None, tags=None, sku = Sku(sku_name) return client.update(resource_group_name, account_name, sku, tags) -def checkskuavailability(location=None, sku_name=None, kind=None, type=None): - from azure.cli.core.commands.client_factory import get_mgmt_service_client - from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient - checkskuclient = get_mgmt_service_client(CognitiveServicesManagementClient, location=location).check_sku_availability - sku = [] - sku.append(Sku(sku_name)) - return checkskuclient.list(sku, kind, type) \ No newline at end of file diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml index fc8f0ff7a1b..2f5305daf12 100644 --- a/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml +++ b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml @@ -20,11 +20,11 @@ interactions: cache-control: [no-cache] content-length: ['326'] content-type: [application/json; charset=utf-8] - date: ['Wed, 26 Apr 2017 22:28:34 GMT'] + date: ['Thu, 27 Apr 2017 17:45:39 GMT'] expires: ['-1'] pragma: [no-cache] strict-transport-security: [max-age=31536000; includeSubDomains] - x-ms-ratelimit-remaining-subscription-writes: ['1194'] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] status: {code: 201, message: Created} - request: body: '{"sku": {"name": "S0"}, "kind": "Face", "location": "westeurope", "properties": @@ -43,19 +43,19 @@ interactions: method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"00000629-0000-0000-0000-59011f150000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"27ec2778887649f28ebd3debd4aebfd2","dateCreated":"2017-04-26T22:28:38.586638Z","provisioningState":"Succeeded"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"0000492e-0000-0000-0000-59022e480000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"75902ed953574433aba22ba9b886ed14","dateCreated":"2017-04-27T17:45:45.7327082Z","provisioningState":"Succeeded"}}'} headers: cache-control: [no-cache] - content-length: ['595'] + content-length: ['596'] content-type: [application/json; charset=utf-8] - date: ['Wed, 26 Apr 2017 22:28:37 GMT'] - etag: ['"00000629-0000-0000-0000-59011f150000"'] + date: ['Thu, 27 Apr 2017 17:45:44 GMT'] + etag: ['"0000492e-0000-0000-0000-59022e480000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] strict-transport-security: [max-age=31536000; includeSubDomains] x-aspnet-version: [4.0.30319] - x-ms-ratelimit-remaining-subscription-writes: ['1197'] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-powered-by: [ASP.NET] status: {code: 201, message: Created} - request: @@ -73,13 +73,13 @@ interactions: method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"00000629-0000-0000-0000-59011f150000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"27ec2778887649f28ebd3debd4aebfd2","dateCreated":"2017-04-26T22:28:38.586638Z","provisioningState":"Succeeded"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"0000492e-0000-0000-0000-59022e480000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"75902ed953574433aba22ba9b886ed14","dateCreated":"2017-04-27T17:45:45.7327082Z","provisioningState":"Succeeded"}}'} headers: cache-control: [no-cache] - content-length: ['595'] + content-length: ['596'] content-type: [application/json; charset=utf-8] - date: ['Wed, 26 Apr 2017 22:28:38 GMT'] - etag: ['"00000629-0000-0000-0000-59011f150000"'] + date: ['Thu, 27 Apr 2017 17:45:46 GMT'] + etag: ['"0000492e-0000-0000-0000-59022e480000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -105,13 +105,13 @@ interactions: method: PATCH uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00000829-0000-0000-0000-59011f180000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"27ec2778887649f28ebd3debd4aebfd2","dateCreated":"2017-04-26T22:28:38.586638Z"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00004b2e-0000-0000-0000-59022e4c0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"75902ed953574433aba22ba9b886ed14","dateCreated":"2017-04-27T17:45:45.7327082Z"}}'} headers: cache-control: [no-cache] - content-length: ['630'] + content-length: ['631'] content-type: [application/json; charset=utf-8] - date: ['Wed, 26 Apr 2017 22:28:41 GMT'] - etag: ['"00000829-0000-0000-0000-59011f180000"'] + date: ['Thu, 27 Apr 2017 17:45:48 GMT'] + etag: ['"00004b2e-0000-0000-0000-59022e4c0000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -119,7 +119,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-aspnet-version: [4.0.30319] - x-ms-ratelimit-remaining-subscription-writes: ['1191'] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-powered-by: [ASP.NET] status: {code: 200, message: OK} - request: @@ -138,12 +138,12 @@ interactions: method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/listKeys?api-version=2017-04-18 response: - body: {string: '{"key1":"308d345d568c491ab80e8f056070e2ef","key2":"957b9bcbd4884bd68226a03179f79b22"}'} + body: {string: '{"key1":"4442166528264e9586ab803f69f2c22d","key2":"aedc31494ba2497ebd9227204351c4f3"}'} headers: cache-control: [no-cache] content-length: ['85'] content-type: [application/json; charset=utf-8] - date: ['Wed, 26 Apr 2017 22:28:42 GMT'] + date: ['Thu, 27 Apr 2017 17:45:50 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -151,7 +151,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-aspnet-version: [4.0.30319] - x-ms-ratelimit-remaining-subscription-writes: ['1197'] + x-ms-ratelimit-remaining-subscription-writes: ['1198'] x-powered-by: [ASP.NET] status: {code: 200, message: OK} - request: @@ -170,12 +170,12 @@ interactions: method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/regenerateKey?api-version=2017-04-18 response: - body: {string: '{"key1":"cd2218fd4cef480ea7847b086410bd29","key2":"957b9bcbd4884bd68226a03179f79b22"}'} + body: {string: '{"key1":"45ac4197f4e749d78d148b9f3b4c4265","key2":"aedc31494ba2497ebd9227204351c4f3"}'} headers: cache-control: [no-cache] content-length: ['85'] content-type: [application/json; charset=utf-8] - date: ['Wed, 26 Apr 2017 22:28:44 GMT'] + date: ['Thu, 27 Apr 2017 17:45:52 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -183,7 +183,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-aspnet-version: [4.0.30319] - x-ms-ratelimit-remaining-subscription-writes: ['1198'] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-powered-by: [ASP.NET] status: {code: 200, message: OK} - request: @@ -201,12 +201,12 @@ interactions: method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts?api-version=2017-04-18 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00000c29-0000-0000-0000-59011f1c0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"27ec2778887649f28ebd3debd4aebfd2","dateCreated":"2017-04-26T22:28:38.586638Z"}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00004f2e-0000-0000-0000-59022e500000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"75902ed953574433aba22ba9b886ed14","dateCreated":"2017-04-27T17:45:45.7327082Z"}}]}'} headers: cache-control: [no-cache] - content-length: ['642'] + content-length: ['643'] content-type: [application/json; charset=utf-8] - date: ['Wed, 26 Apr 2017 22:28:46 GMT'] + date: ['Thu, 27 Apr 2017 17:45:53 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -216,6 +216,35 @@ interactions: x-aspnet-version: [4.0.30319] x-powered-by: [ASP.NET] status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [cognitiveservices account delete] + Connection: [keep-alive] + Content-Length: ['0'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 + msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python + AZURECLI/2.0.3+dev] + accept-language: [en-US] + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 + response: + body: {string: ''} + headers: + cache-control: [no-cache] + content-length: ['0'] + date: ['Thu, 27 Apr 2017 17:45:55 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-IIS/8.5] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-aspnet-version: [4.0.30319] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] + x-powered-by: [ASP.NET] + status: {code: 200, message: OK} - request: body: null headers: @@ -236,12 +265,12 @@ interactions: headers: cache-control: [no-cache] content-length: ['0'] - date: ['Wed, 26 Apr 2017 22:28:46 GMT'] + date: ['Thu, 27 Apr 2017 17:45:56 GMT'] expires: ['-1'] - location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkc4NEEyMkRFOTYyRTBCNDgxOUJCODA2ODMxNUJGMzk2Mjg4Mnw1RUZEM0E2NDMyRDg0RjU3LVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkdBMjE0MTkzM0RDQTgwODQxRjVFQ0NENEQ2RTREOUVEOTY1RXw3ODg4NUQ5N0E1QzNCMzdGLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] pragma: [no-cache] retry-after: ['15'] strict-transport-security: [max-age=31536000; includeSubDomains] - x-ms-ratelimit-remaining-subscription-writes: ['1197'] + x-ms-ratelimit-remaining-subscription-writes: ['1198'] status: {code: 202, message: Accepted} version: 1 diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py index 9d0070f48c8..e43a65552d3 100644 --- a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py +++ b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py @@ -56,8 +56,8 @@ def test_cognitiveservices(self, resource_group): assert oldkeys != newkeys #test to list cognitive service accounts under current resource group - resourceResult = self.cmd('az cognitiveservices list -g {}'.format(resource_group)).get_output_in_json() - JMESPathCheck(contains(resourceResult, sname), True) + self.cmd('az cognitiveservices list -g {}'.format(resource_group), checks=[ + JMESPathCheck('length(@)', 1)]) #test to delete the cognitive services account exitcode= self.cmd('az cognitiveservices account delete -n {} -g {}'.format( From fc47810cb1a138055f16fcb6ec0960c7ba6b56d4 Mon Sep 17 00:00:00 2001 From: kostenray Date: Thu, 27 Apr 2017 21:59:24 -0700 Subject: [PATCH 07/15] update --- azure-cli.pyproj | 3 +++ .../azure-cli-cognitiveservices/HISTORY.rst | 10 ++++++++++ .../azure-cli-cognitiveservices/MANIFEST.in | 1 + .../azure-cli-cognitiveservices/README.rst | 8 ++++++-- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/command_modules/azure-cli-cognitiveservices/HISTORY.rst create mode 100644 src/command_modules/azure-cli-cognitiveservices/MANIFEST.in diff --git a/azure-cli.pyproj b/azure-cli.pyproj index f8513b1f0f0..051bc27c877 100644 --- a/azure-cli.pyproj +++ b/azure-cli.pyproj @@ -843,6 +843,9 @@ + + + diff --git a/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst b/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst new file mode 100644 index 00000000000..fce09cd9fa4 --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst @@ -0,0 +1,10 @@ +.. :changelog: + +Unreleased +-------------------------- +* inital cognitive services CLI + + +Release History +=============== + diff --git a/src/command_modules/azure-cli-cognitiveservices/MANIFEST.in b/src/command_modules/azure-cli-cognitiveservices/MANIFEST.in new file mode 100644 index 00000000000..bb37a2723da --- /dev/null +++ b/src/command_modules/azure-cli-cognitiveservices/MANIFEST.in @@ -0,0 +1 @@ +include *.rst diff --git a/src/command_modules/azure-cli-cognitiveservices/README.rst b/src/command_modules/azure-cli-cognitiveservices/README.rst index 72952fff618..11991a8b8ae 100644 --- a/src/command_modules/azure-cli-cognitiveservices/README.rst +++ b/src/command_modules/azure-cli-cognitiveservices/README.rst @@ -1,3 +1,7 @@ -Microsoft Azure CLI 'example' Command Module -================================== +Microsoft Azure CLI 'cognitive services' Command Module +============================================= + +This package is for the 'cognitive services' module. +i.e. 'az cognitiveservices' + From d26c098ba150b204e47b368d915879328b359b4f Mon Sep 17 00:00:00 2001 From: kostenray Date: Fri, 28 Apr 2017 20:34:28 -0700 Subject: [PATCH 08/15] change the term text to yellow highlighted --- .../azure/cli/command_modules/cognitiveservices/custom.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py index 08fc7ed56a0..21785b73093 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py @@ -23,7 +23,8 @@ def create(client, resource_group_name, account_name, sku_name, kind, location, if yes: logger.warning(terms) else: - option = prompt_y_n(terms + hint) + logger.warning(terms) + option = prompt_y_n(hint) if(not option): raise CLIError('Operation cancelled.') sku = Sku(sku_name) From 1b9e313b9f41440a3013847f0cdbf84ab6046ed5 Mon Sep 17 00:00:00 2001 From: kostenray Date: Mon, 1 May 2017 13:17:29 -0700 Subject: [PATCH 09/15] code comment fix - update #1 --- .../azure-cli-cognitiveservices/HISTORY.rst | 7 ++-- .../cognitiveservices/_client_factory.py | 15 +++---- .../cognitiveservices/_help.py | 4 +- .../cognitiveservices/_params.py | 9 +---- .../cognitiveservices/commands.py | 39 +++++++++++-------- .../cognitiveservices/custom.py | 18 +++++---- .../azure-cli-cognitiveservices/setup.py | 16 +++++--- .../tests/test_cognitiveservices_command.py | 8 +--- 8 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst b/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst index fce09cd9fa4..59c2bcdedc2 100644 --- a/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst +++ b/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst @@ -1,10 +1,9 @@ .. :changelog: +Release History +=============== + Unreleased -------------------------- * inital cognitive services CLI - -Release History -=============== - diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py index 63867fe4305..8baf006d0ec 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py @@ -2,13 +2,14 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- - -def cognitiveservices_client_factory(_): +#management client factories +def get_cognitiveservices_management_client(_): from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient - return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused').cognitive_services_accounts + return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused') -def cognitiveservices_account_client_factory(_): - from azure.cli.core.commands.client_factory import get_mgmt_service_client - from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient - return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused').accounts +def get_cognitiveservices_account_operations(kwargs): + return get_cognitiveservices_management_client(kwargs).cognitive_services_accounts + +def get_cognitiveservices_operations(kwargs): + return get_cognitiveservices_management_client(kwargs).accounts diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py index 0520c4ca5a1..0ff1f637700 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py @@ -33,8 +33,8 @@ type: command short-summary: Create a cognitive services account. examples: - - name: create a S0 face Api cognitive services accounts in West Europe without confirmation required - text: az cognitiveservices create -n myresource -g myResrouceGroup --Kind Face --Sku S0 -l WestEurope --yes + - name: create a S0 face Api cognitive services account in West Europe without confirmation required + text: az cognitiveservices create -n myresource -g myResourceGroup --kind Face --sku S0 -l WestEurope --yes """ helps['cognitiveservices account show'] = """ diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py index 8be5e5e3a58..40831efe0fc 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py @@ -2,8 +2,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- - -# pylint: disable=line-too-long import os import platform from azure.mgmt.cognitiveservices.models import SkuName @@ -25,9 +23,4 @@ register_cli_argument('cognitiveservices', 'kind', help='the API name of cognitive services account') register_cli_argument('cognitiveservices', 'tags', tags_type) register_cli_argument('cognitiveservices', 'key_name', required=True, help='Key name to generate', choices=['key1', 'key2']) -register_cli_argument('cognitiveservices account create', 'yes', action='store_true', help='Do not prompt for terms confirmation') - - - - - +register_cli_argument('cognitiveservices account create', 'yes', action='store_true', help='Do not prompt for terms confirmation') \ No newline at end of file diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py index e6b43418104..5bc36f2cde4 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py @@ -2,23 +2,28 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- - -# pylint: disable=line-too-long - from azure.cli.core.commands import cli_command +from azure.cli.command_modules.cognitiveservices._client_factory import ( + get_cognitiveservices_account_operations, + get_cognitiveservices_operations) -from azure.cli.command_modules.cognitiveservices._client_factory import cognitiveservices_client_factory, cognitiveservices_account_client_factory - -mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#CognitiveServicesAccountsOperations.' -custom_path = 'azure.cli.command_modules.cognitiveservices.custom#' - -cli_command(__name__, 'cognitiveservices account create', custom_path + 'create', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices account delete', mgmt_path + 'delete', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices account show', mgmt_path + 'get_properties', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices list', custom_path + 'list', cognitiveservices_account_client_factory) -cli_command(__name__, 'cognitiveservices account update', custom_path + 'update', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices account keys regenerate', mgmt_path + 'regenerate_key', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices account keys list', mgmt_path + 'list_keys', cognitiveservices_client_factory) -cli_command(__name__, 'cognitiveservices account list-skus', mgmt_path + 'list_skus', cognitiveservices_client_factory) - +mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#'\ +'CognitiveServicesAccountsOperations.{}' +custom_path = 'azure.cli.command_modules.cognitiveservices.custom#{}' +cli_command(__name__, 'cognitiveservices account create', custom_path.format('create'), + get_cognitiveservices_account_operations) +cli_command(__name__, 'cognitiveservices account delete', mgmt_path.format('delete'), + get_cognitiveservices_account_operations) +cli_command(__name__, 'cognitiveservices account show', mgmt_path.format('get_properties'), + get_cognitiveservices_account_operations) +cli_command(__name__, 'cognitiveservices list', custom_path.format('list'), + get_cognitiveservices_operations) +cli_command(__name__, 'cognitiveservices account update', custom_path.format('update'), + get_cognitiveservices_account_operations) +cli_command(__name__, 'cognitiveservices account keys regenerate', mgmt_path.format('regenerate_key'), + get_cognitiveservices_account_operations) +cli_command(__name__, 'cognitiveservices account keys list', mgmt_path.format('list_keys'), + get_cognitiveservices_account_operations) +cli_command(__name__, 'cognitiveservices account list-skus', mgmt_path.format('list_skus'), + get_cognitiveservices_account_operations) \ No newline at end of file diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py index 21785b73093..281a1ad9608 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.mgmt.cognitiveservices.models import CognitiveServicesAccountCreateParameters, Sku, SkuName, CognitiveServicesAccountUpdateParameters -from azure.cli.core.prompting import prompt_y_n, NoTTYException +from azure.mgmt.cognitiveservices.models import CognitiveServicesAccountCreateParameters, Sku +from azure.cli.core.prompting import prompt_y_n from azure.cli.core.util import CLIError import azure.cli.core.azlogging as azlogging @@ -16,10 +16,12 @@ def list(client, resource_group_name=None): else: return client.list() -def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None, **kwargs): +def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None): - terms = 'Notice\nMicrosoft may use data you send to the Cognitive Services to improve Microsoft products and services. For example we may use content that you provide to the Cognitive Services to improve our underlying algorithms and models over time. Where you send personal data to the Cognitive Services, you are responsible for obtaining sufficient consent from the data subjects. The General Privacy and Security Terms in the Online Services Terms (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) do not apply to the Cognitive Services. You must comply with use and display requirements for the Bing Search APIs. \n\nPlease refer to the Microsoft Cognitive Services section in the Online Services Terms for details.' - hint= '\nPlease select' + terms = 'Notice\nMicrosoft may use data you send to the Cognitive Services to improve Microsoft products and services.'\ + 'For example we may use content that you provide to the Cognitive Services to improve our underlying algorithms and models over time.'\ + 'Where you send personal data to the Cognitive Services, you are responsible for obtaining sufficient consent from the data subjects. The General Privacy and Security Terms in the Online Services Terms (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) do not apply to the Cognitive Services. You must comply with use and display requirements for the Bing Search APIs. \n\nPlease refer to the Microsoft Cognitive Services section in the Online Services Terms for details.' + hint = '\nPlease select' if yes: logger.warning(terms) else: @@ -27,12 +29,12 @@ def create(client, resource_group_name, account_name, sku_name, kind, location, option = prompt_y_n(hint) if(not option): raise CLIError('Operation cancelled.') - sku = Sku(sku_name) - properties= {} + sku = Sku(sku_name) + properties = {} params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags) return client.create(resource_group_name, account_name, params) -def update(client, resource_group_name, account_name, sku_name=None, tags=None, **kwargs): +def update(client, resource_group_name, account_name, sku_name=None, tags=None): sku = Sku(sku_name) return client.update(resource_group_name, account_name, sku, tags) diff --git a/src/command_modules/azure-cli-cognitiveservices/setup.py b/src/command_modules/azure-cli-cognitiveservices/setup.py index f3cd6112e20..3ffcd02513d 100644 --- a/src/command_modules/azure-cli-cognitiveservices/setup.py +++ b/src/command_modules/azure-cli-cognitiveservices/setup.py @@ -7,6 +7,13 @@ from codecs import open from setuptools import setup +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 = {} + # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers CLASSIFIERS = [ @@ -30,7 +37,7 @@ setup( name='azure-cli-cognitiveservices', - version='1.0.0', + version='0.1.0', description='Microsoft Azure Command-Line Tools Cognitive Services Command Module', long_description=README, license='MIT', @@ -38,13 +45,12 @@ author_email='azpycli@microsoft.com', url='https://github.com/azure/azure-cli', classifiers=CLASSIFIERS, - namespace_packages = [ + packages=[ 'azure', 'azure.cli', 'azure.cli.command_modules', - ], - packages=[ 'azure.cli.command_modules.cognitiveservices', ], install_requires=DEPENDENCIES, -) + cmdclass=cmdclass +) \ No newline at end of file diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py index e43a65552d3..78c8d2716f7 100644 --- a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py +++ b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py @@ -2,12 +2,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- - -#pylint: disable=method-hidden -#pylint: disable=line-too-long -#pylint: disable=bad-continuation -#from _future_ import print_function - import os import time import unittest @@ -18,7 +12,7 @@ class CognitiveServicesTests(ScenarioTest): @ResourceGroupPreparer() - def test_cognitiveservices(self, resource_group): + def test_CRUDOperations_cognitiveservices(self, resource_group): sname = self.create_random_name(prefix='cog', length=12) resource_location = 'westeurope' From b6c66432f5a3cf58f7127c7a892935b7ea99464c Mon Sep 17 00:00:00 2001 From: kostenray Date: Mon, 1 May 2017 16:14:34 -0700 Subject: [PATCH 10/15] fix code comments - update #2 --- .../azure/cli/testsdk/base.py | 2 +- .../cognitiveservices/__init__.py | 6 +-- .../cognitiveservices/_help.py | 5 --- .../cognitiveservices/_params.py | 28 ++++++------ .../cognitiveservices/commands.py | 11 ++--- .../cognitiveservices/custom.py | 35 ++++++++++----- .../azure-cli-cognitiveservices/setup.py | 1 - ....yaml => test_cognitiveservices_crud.yaml} | 44 +++++++++---------- .../tests/test_cognitiveservices_command.py | 2 +- 9 files changed, 71 insertions(+), 63 deletions(-) rename src/command_modules/azure-cli-cognitiveservices/tests/recordings/{test_cognitiveservices.yaml => test_cognitiveservices_crud.yaml} (86%) diff --git a/src/azure-cli-testsdk/azure/cli/testsdk/base.py b/src/azure-cli-testsdk/azure/cli/testsdk/base.py index 744919f3868..cb9fc460203 100644 --- a/src/azure-cli-testsdk/azure/cli/testsdk/base.py +++ b/src/azure-cli-testsdk/azure/cli/testsdk/base.py @@ -31,7 +31,7 @@ class IntegrationTestBase(unittest.TestCase): def __init__(self, method_name): super(IntegrationTestBase, self).__init__(method_name) - self.diagnose = True #os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' + self.diagnose = os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' def cmd(self, command, checks=None, expect_failure=False): if self.diagnose: diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py index 691b2d5297c..4481d77fd8e 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py @@ -4,9 +4,9 @@ # -------------------------------------------------------------------------------------------- import azure.cli.command_modules.cognitiveservices._help # pylint: disable=unused-import -def load_params(command): - import azure.cli.command_modules.cognitiveservices._params +def load_params(_): + import azure.cli.command_modules.cognitiveservices._params #pylint: disable=redefined-outer-name def load_commands(): - import azure.cli.command_modules.cognitiveservices.commands + import azure.cli.command_modules.cognitiveservices.commands #pylint: disable=redefined-outer-name diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py index 0ff1f637700..f14d74a87ac 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py @@ -13,11 +13,6 @@ text: az cognitiveservices list -g MyResourceGroup """ -#helps['cognitiveservices checkskuavailability'] = """ -# type: command -# short-summary: check the available skus -#""" - helps['cognitiveservices account'] = """ type: group short-summary: Manage and update cognitive services accounts diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py index 40831efe0fc..a2fe21f56ab 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py @@ -2,25 +2,27 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -import os -import platform -from azure.mgmt.cognitiveservices.models import SkuName +from azure.cli.core.commands import register_cli_argument, CliArgumentType -from azure.cli.core.commands import register_cli_argument, CliArgumentType, register_extra_cli_argument from azure.cli.core.commands.parameters import ( - enum_choice_list, - file_type, tags_type, resource_group_name_type, - get_one_of_subscription_locations, get_resource_name_completion_list) name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME') -register_cli_argument('cognitiveservices', 'account_name', arg_type=name_arg_type, help='cognitive service account name', completer=get_resource_name_completion_list('Microsoft.CognitiveServices/accounts')) -register_cli_argument('cognitiveservices', 'resource_group_name', arg_type=resource_group_name_type) -register_cli_argument('cognitiveservices', 'sku_name', options_list=('--sku',), help='the Sku of cognitive services account') -register_cli_argument('cognitiveservices', 'kind', help='the API name of cognitive services account') +register_cli_argument('cognitiveservices', 'account_name', + arg_type=name_arg_type, help='cognitive service account name', + completer=get_resource_name_completion_list( + 'Microsoft.CognitiveServices/accounts')) +register_cli_argument('cognitiveservices', 'resource_group_name', + arg_type=resource_group_name_type) +register_cli_argument('cognitiveservices', 'sku_name', options_list=('--sku',), + help='the Sku of cognitive services account') +register_cli_argument('cognitiveservices', 'kind', + help='the API name of cognitive services account') register_cli_argument('cognitiveservices', 'tags', tags_type) -register_cli_argument('cognitiveservices', 'key_name', required=True, help='Key name to generate', choices=['key1', 'key2']) -register_cli_argument('cognitiveservices account create', 'yes', action='store_true', help='Do not prompt for terms confirmation') \ No newline at end of file +register_cli_argument('cognitiveservices', 'key_name', required=True, + help='Key name to generate', choices=['key1', 'key2']) +register_cli_argument('cognitiveservices account create', 'yes', action='store_true', + help='Do not prompt for terms confirmation') diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py index 5bc36f2cde4..eacbd60938b 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py @@ -4,8 +4,8 @@ # -------------------------------------------------------------------------------------------- from azure.cli.core.commands import cli_command from azure.cli.command_modules.cognitiveservices._client_factory import ( - get_cognitiveservices_account_operations, - get_cognitiveservices_operations) + get_cognitiveservices_account_operations, + get_cognitiveservices_operations) mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#'\ 'CognitiveServicesAccountsOperations.{}' @@ -17,13 +17,14 @@ get_cognitiveservices_account_operations) cli_command(__name__, 'cognitiveservices account show', mgmt_path.format('get_properties'), get_cognitiveservices_account_operations) -cli_command(__name__, 'cognitiveservices list', custom_path.format('list'), +cli_command(__name__, 'cognitiveservices list', custom_path.format('listresources'), get_cognitiveservices_operations) cli_command(__name__, 'cognitiveservices account update', custom_path.format('update'), get_cognitiveservices_account_operations) -cli_command(__name__, 'cognitiveservices account keys regenerate', mgmt_path.format('regenerate_key'), +cli_command(__name__, 'cognitiveservices account keys regenerate', + mgmt_path.format('regenerate_key'), get_cognitiveservices_account_operations) cli_command(__name__, 'cognitiveservices account keys list', mgmt_path.format('list_keys'), get_cognitiveservices_account_operations) cli_command(__name__, 'cognitiveservices account list-skus', mgmt_path.format('list_skus'), - get_cognitiveservices_account_operations) \ No newline at end of file + get_cognitiveservices_account_operations) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py index 281a1ad9608..85ae6b418b2 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py @@ -10,32 +10,43 @@ logger = azlogging.get_az_logger(__name__) -def list(client, resource_group_name=None): - if resource_group_name: - return client.list_by_resource_group(resource_group_name) +def listresources(client, resource_group_name=None): + if resource_group_name: + return client.list_by_resource_group(resource_group_name) else: - return client.list() + return client.list() -def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None): - - terms = 'Notice\nMicrosoft may use data you send to the Cognitive Services to improve Microsoft products and services.'\ - 'For example we may use content that you provide to the Cognitive Services to improve our underlying algorithms and models over time.'\ - 'Where you send personal data to the Cognitive Services, you are responsible for obtaining sufficient consent from the data subjects. The General Privacy and Security Terms in the Online Services Terms (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) do not apply to the Cognitive Services. You must comply with use and display requirements for the Bing Search APIs. \n\nPlease refer to the Microsoft Cognitive Services section in the Online Services Terms for details.' +# pylint: disable=too-many-arguments +def create( + client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None): + + terms = 'Notice\nMicrosoft may use data you send to the Cognitive'\ + 'Services to improve Microsoft products and services.'\ + 'For example we may use content that you provide to the Cognitive'\ + 'Services to improve our underlying algorithms and models over time.'\ + 'Where you send personal data to the Cognitive Services, you are responsible'\ + 'for obtaining sufficient consent from the data subjects.'\ + 'The General Privacy and Security Terms in the Online Services Terms '\ + '(https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) '\ + 'do not apply to the Cognitive Services.'\ + 'You must comply with use and display requirements for the Bing Search APIs.'\ + '\n\nPlease refer to the Microsoft Cognitive Services section in the Online '\ + 'Services Terms for details.' hint = '\nPlease select' if yes: logger.warning(terms) else: logger.warning(terms) option = prompt_y_n(hint) - if(not option): - raise CLIError('Operation cancelled.') + if not option: + raise CLIError('Operation cancelled.') sku = Sku(sku_name) properties = {} params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags) return client.create(resource_group_name, account_name, params) def update(client, resource_group_name, account_name, sku_name=None, tags=None): - sku = Sku(sku_name) + sku = Sku(sku_name) return client.update(resource_group_name, account_name, sku, tags) diff --git a/src/command_modules/azure-cli-cognitiveservices/setup.py b/src/command_modules/azure-cli-cognitiveservices/setup.py index 3ffcd02513d..cefa55bd076 100644 --- a/src/command_modules/azure-cli-cognitiveservices/setup.py +++ b/src/command_modules/azure-cli-cognitiveservices/setup.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml similarity index 86% rename from src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml rename to src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml index 2f5305daf12..a4ad169dca4 100644 --- a/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices.yaml +++ b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml @@ -20,7 +20,7 @@ interactions: cache-control: [no-cache] content-length: ['326'] content-type: [application/json; charset=utf-8] - date: ['Thu, 27 Apr 2017 17:45:39 GMT'] + date: ['Mon, 01 May 2017 23:13:21 GMT'] expires: ['-1'] pragma: [no-cache] strict-transport-security: [max-age=31536000; includeSubDomains] @@ -43,13 +43,13 @@ interactions: method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"0000492e-0000-0000-0000-59022e480000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"75902ed953574433aba22ba9b886ed14","dateCreated":"2017-04-27T17:45:45.7327082Z","provisioningState":"Succeeded"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"0000b805-0000-0000-0000-5907c1110000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"fa364912921a4b5c84206c4380af3e46","dateCreated":"2017-05-01T23:13:23.9947901Z","provisioningState":"Succeeded"}}'} headers: cache-control: [no-cache] content-length: ['596'] content-type: [application/json; charset=utf-8] - date: ['Thu, 27 Apr 2017 17:45:44 GMT'] - etag: ['"0000492e-0000-0000-0000-59022e480000"'] + date: ['Mon, 01 May 2017 23:13:22 GMT'] + etag: ['"0000b805-0000-0000-0000-5907c1110000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -73,13 +73,13 @@ interactions: method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"0000492e-0000-0000-0000-59022e480000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"75902ed953574433aba22ba9b886ed14","dateCreated":"2017-04-27T17:45:45.7327082Z","provisioningState":"Succeeded"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"0000b805-0000-0000-0000-5907c1110000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"fa364912921a4b5c84206c4380af3e46","dateCreated":"2017-05-01T23:13:23.9947901Z","provisioningState":"Succeeded"}}'} headers: cache-control: [no-cache] content-length: ['596'] content-type: [application/json; charset=utf-8] - date: ['Thu, 27 Apr 2017 17:45:46 GMT'] - etag: ['"0000492e-0000-0000-0000-59022e480000"'] + date: ['Mon, 01 May 2017 23:13:24 GMT'] + etag: ['"0000b805-0000-0000-0000-5907c1110000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -105,13 +105,13 @@ interactions: method: PATCH uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00004b2e-0000-0000-0000-59022e4c0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"75902ed953574433aba22ba9b886ed14","dateCreated":"2017-04-27T17:45:45.7327082Z"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"0000ba05-0000-0000-0000-5907c1140000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"fa364912921a4b5c84206c4380af3e46","dateCreated":"2017-05-01T23:13:23.9947901Z"}}'} headers: cache-control: [no-cache] content-length: ['631'] content-type: [application/json; charset=utf-8] - date: ['Thu, 27 Apr 2017 17:45:48 GMT'] - etag: ['"00004b2e-0000-0000-0000-59022e4c0000"'] + date: ['Mon, 01 May 2017 23:13:26 GMT'] + etag: ['"0000ba05-0000-0000-0000-5907c1140000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -119,7 +119,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-aspnet-version: [4.0.30319] - x-ms-ratelimit-remaining-subscription-writes: ['1199'] + x-ms-ratelimit-remaining-subscription-writes: ['1198'] x-powered-by: [ASP.NET] status: {code: 200, message: OK} - request: @@ -138,12 +138,12 @@ interactions: method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/listKeys?api-version=2017-04-18 response: - body: {string: '{"key1":"4442166528264e9586ab803f69f2c22d","key2":"aedc31494ba2497ebd9227204351c4f3"}'} + body: {string: '{"key1":"a0575889d7534fa0a8750c2c05c7e9a1","key2":"5c9fd8926982491e99acb650a6eb2315"}'} headers: cache-control: [no-cache] content-length: ['85'] content-type: [application/json; charset=utf-8] - date: ['Thu, 27 Apr 2017 17:45:50 GMT'] + date: ['Mon, 01 May 2017 23:13:27 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -151,7 +151,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-aspnet-version: [4.0.30319] - x-ms-ratelimit-remaining-subscription-writes: ['1198'] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-powered-by: [ASP.NET] status: {code: 200, message: OK} - request: @@ -170,12 +170,12 @@ interactions: method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/regenerateKey?api-version=2017-04-18 response: - body: {string: '{"key1":"45ac4197f4e749d78d148b9f3b4c4265","key2":"aedc31494ba2497ebd9227204351c4f3"}'} + body: {string: '{"key1":"ee576aab47ef4800aa547f74e84bb47f","key2":"5c9fd8926982491e99acb650a6eb2315"}'} headers: cache-control: [no-cache] content-length: ['85'] content-type: [application/json; charset=utf-8] - date: ['Thu, 27 Apr 2017 17:45:52 GMT'] + date: ['Mon, 01 May 2017 23:13:28 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -201,12 +201,12 @@ interactions: method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts?api-version=2017-04-18 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00004f2e-0000-0000-0000-59022e500000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"75902ed953574433aba22ba9b886ed14","dateCreated":"2017-04-27T17:45:45.7327082Z"}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"0000be05-0000-0000-0000-5907c1170000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"fa364912921a4b5c84206c4380af3e46","dateCreated":"2017-05-01T23:13:23.9947901Z"}}]}'} headers: cache-control: [no-cache] content-length: ['643'] content-type: [application/json; charset=utf-8] - date: ['Thu, 27 Apr 2017 17:45:53 GMT'] + date: ['Mon, 01 May 2017 23:13:29 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -236,7 +236,7 @@ interactions: headers: cache-control: [no-cache] content-length: ['0'] - date: ['Thu, 27 Apr 2017 17:45:55 GMT'] + date: ['Mon, 01 May 2017 23:13:32 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -265,12 +265,12 @@ interactions: headers: cache-control: [no-cache] content-length: ['0'] - date: ['Thu, 27 Apr 2017 17:45:56 GMT'] + date: ['Mon, 01 May 2017 23:13:32 GMT'] expires: ['-1'] - location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkdBMjE0MTkzM0RDQTgwODQxRjVFQ0NENEQ2RTREOUVEOTY1RXw3ODg4NUQ5N0E1QzNCMzdGLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkczREY5ODFEMTMyMDdCMkFGRUM5RjU5RUI2NjYwOUU4RkQ3RHwyNzAzMkVENUQ0QzE2RDgzLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] pragma: [no-cache] retry-after: ['15'] strict-transport-security: [max-age=31536000; includeSubDomains] - x-ms-ratelimit-remaining-subscription-writes: ['1198'] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] status: {code: 202, message: Accepted} version: 1 diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py index 78c8d2716f7..82479f3390e 100644 --- a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py +++ b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py @@ -12,7 +12,7 @@ class CognitiveServicesTests(ScenarioTest): @ResourceGroupPreparer() - def test_CRUDOperations_cognitiveservices(self, resource_group): + def test_cognitiveservices_crud(self, resource_group): sname = self.create_random_name(prefix='cog', length=12) resource_location = 'westeurope' From 25adc1648947f638aa3ec943cfa5f40712013409 Mon Sep 17 00:00:00 2001 From: kostenray Date: Mon, 1 May 2017 22:42:25 -0700 Subject: [PATCH 11/15] 1.fix flake 8 styling error 2. add the depedencies in setup, --- .../cognitiveservices/__init__.py | 7 +++-- .../cognitiveservices/_client_factory.py | 6 +++- .../cognitiveservices/_help.py | 8 ++--- .../cognitiveservices/commands.py | 2 +- .../cognitiveservices/custom.py | 5 ++- .../azure-cli-cognitiveservices/setup.py | 16 +++++----- .../tests/test_cognitiveservices_command.py | 31 +++++++++---------- 7 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py index 4481d77fd8e..6c8efe8cb7d 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py @@ -4,9 +4,10 @@ # -------------------------------------------------------------------------------------------- import azure.cli.command_modules.cognitiveservices._help # pylint: disable=unused-import + def load_params(_): - import azure.cli.command_modules.cognitiveservices._params #pylint: disable=redefined-outer-name + import azure.cli.command_modules.cognitiveservices._params # pylint: disable=redefined-outer-name -def load_commands(): - import azure.cli.command_modules.cognitiveservices.commands #pylint: disable=redefined-outer-name +def load_commands(): + import azure.cli.command_modules.cognitiveservices.commands # pylint: disable=redefined-outer-name diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py index 8baf006d0ec..e8d12a17da3 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py @@ -2,14 +2,18 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -#management client factories +# management client factories + + def get_cognitiveservices_management_client(_): from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused') + def get_cognitiveservices_account_operations(kwargs): return get_cognitiveservices_management_client(kwargs).cognitive_services_accounts + def get_cognitiveservices_operations(kwargs): return get_cognitiveservices_management_client(kwargs).accounts diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py index f14d74a87ac..b7e68d3ca66 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py @@ -9,14 +9,13 @@ type: command short-summary: list all the existing cognitive services accounts under a resource group or current azure subscription examples: - - name: list all the cognitive services accounts in a resource group - text: az cognitiveservices list -g MyResourceGroup + - name: list all the cognitive services accounts in a resource group + text: az cognitiveservices list -g MyResourceGroup """ helps['cognitiveservices account'] = """ type: group short-summary: Manage and update cognitive services accounts - """ helps['cognitiveservices account delete'] = """ @@ -62,6 +61,3 @@ type: command short-summary: List the keys of a cognitive services account. """ - - - diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py index eacbd60938b..7de099d5743 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py @@ -8,7 +8,7 @@ get_cognitiveservices_operations) mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#'\ -'CognitiveServicesAccountsOperations.{}' + 'CognitiveServicesAccountsOperations.{}' custom_path = 'azure.cli.command_modules.cognitiveservices.custom#{}' cli_command(__name__, 'cognitiveservices account create', custom_path.format('create'), diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py index 85ae6b418b2..52b58a47663 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py @@ -16,6 +16,7 @@ def listresources(client, resource_group_name=None): else: return client.list() + # pylint: disable=too-many-arguments def create( client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None): @@ -45,9 +46,7 @@ def create( params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags) return client.create(resource_group_name, account_name, params) + def update(client, resource_group_name, account_name, sku_name=None, tags=None): sku = Sku(sku_name) return client.update(resource_group_name, account_name, sku, tags) - - - \ No newline at end of file diff --git a/src/command_modules/azure-cli-cognitiveservices/setup.py b/src/command_modules/azure-cli-cognitiveservices/setup.py index cefa55bd076..1c7247c2ada 100644 --- a/src/command_modules/azure-cli-cognitiveservices/setup.py +++ b/src/command_modules/azure-cli-cognitiveservices/setup.py @@ -6,12 +6,12 @@ from codecs import open from setuptools import setup -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 = {} +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 = {} # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers @@ -29,6 +29,8 @@ ] DEPENDENCIES = [ + 'azure-mgmt-cognitiveservices==1.0.0', + 'azure-cli-core', ] with open('README.rst', 'r', encoding='utf-8') as f: @@ -52,4 +54,4 @@ ], install_requires=DEPENDENCIES, cmdclass=cmdclass -) \ No newline at end of file +) diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py index 82479f3390e..55dc6ec1862 100644 --- a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py +++ b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py @@ -9,56 +9,55 @@ from azure.cli.testsdk import ScenarioTest, JMESPathCheck, ResourceGroupPreparer from azure.cli.core.util import CLIError + class CognitiveServicesTests(ScenarioTest): @ResourceGroupPreparer() - def test_cognitiveservices_crud(self, resource_group): sname = self.create_random_name(prefix='cog', length=12) resource_location = 'westeurope' - #test to create cognitive services account + # test to create cognitive services account self.cmd('az cognitiveservices account create -n {} -g {} --kind {} --sku {} -l {} --yes'.format( sname, resource_group, 'Face', 'S0', resource_location), checks=[ JMESPathCheck('name', sname), JMESPathCheck('location', resource_location), JMESPathCheck('sku.name', 'S0'), JMESPathCheck('provisioningState', 'Succeeded')]) - - #test to show the details of cognitive services account + + # test to show the details of cognitive services account self.cmd('az cognitiveservices account show -n {} -g {}'.format( sname, resource_group), checks=[ JMESPathCheck('name', sname), JMESPathCheck('resourceGroup', resource_group)]) - ##test to update the properties of cognitive servcies account + # test to update the properties of cognitive servcies account tagname = self.create_random_name(prefix='tagname', length=10) - tagvalue= self.create_random_name(prefix='tagvalue', length =10) + tagvalue = self.create_random_name(prefix='tagvalue', length=10) self.cmd('az cognitiveservices account update -n {} -g {} --sku {} --tags {}'.format( sname, resource_group, 'S0', tagname + '=' + tagvalue), checks=[ JMESPathCheck('sku.name', 'S0'), - JMESPathCheck('tags', {tagname:tagvalue})]) - - ##test to list keys of a cogntive services account + JMESPathCheck('tags', {tagname: tagvalue})]) + + # test to list keys of a cogntive services account oldkeys = self.cmd('az cognitiveservices account keys list -n {} -g {}'.format( sname, resource_group), checks=[ JMESPathCheck('length(key1)', 32), JMESPathCheck('length(key2)', 32)]).get_output_in_json() - #test to regenerate the keys of a cognitive services account + # test to regenerate the keys of a cognitive services account newkeys = self.cmd('az cognitiveservices account keys regenerate -n {} -g {} --key-name key1'.format( sname, resource_group)).get_output_in_json() assert oldkeys != newkeys - #test to list cognitive service accounts under current resource group + # test to list cognitive service accounts under current resource group self.cmd('az cognitiveservices list -g {}'.format(resource_group), checks=[ - JMESPathCheck('length(@)', 1)]) + JMESPathCheck('length(@)', 1)]) - #test to delete the cognitive services account - exitcode= self.cmd('az cognitiveservices account delete -n {} -g {}'.format( + # test to delete the cognitive services account + exitcode = self.cmd('az cognitiveservices account delete -n {} -g {}'.format( sname, resource_group)).exit_code assert exitcode == 0 - if __name__ == '__main__': - unittest.main() + unittest.main() From 17db72d2a18b200a8700f497491466a495a1719a Mon Sep 17 00:00:00 2001 From: kostenray Date: Tue, 2 May 2017 00:32:58 -0700 Subject: [PATCH 12/15] fix an change in our service legal terms. --- .../azure/cli/command_modules/cognitiveservices/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py index 52b58a47663..afe5e36b26c 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py @@ -21,7 +21,7 @@ def listresources(client, resource_group_name=None): def create( client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None): - terms = 'Notice\nMicrosoft may use data you send to the Cognitive'\ + terms = 'Notice\nMicrosoft will use data you send to the Cognitive'\ 'Services to improve Microsoft products and services.'\ 'For example we may use content that you provide to the Cognitive'\ 'Services to improve our underlying algorithms and models over time.'\ From 25dd3ea34e223263e2043814b8e30519e0c24405 Mon Sep 17 00:00:00 2001 From: kostenray Date: Tue, 2 May 2017 11:20:44 -0700 Subject: [PATCH 13/15] fix a help.py styling issue --- .../cognitiveservices/_help.py | 2 +- .../test_cognitiveservices_crud.yaml | 48 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py index b7e68d3ca66..444543ef9dc 100644 --- a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py +++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py @@ -10,7 +10,7 @@ short-summary: list all the existing cognitive services accounts under a resource group or current azure subscription examples: - name: list all the cognitive services accounts in a resource group - text: az cognitiveservices list -g MyResourceGroup + text: az cognitiveservices list -g MyResourceGroup """ helps['cognitiveservices account'] = """ diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml index a4ad169dca4..c09240f569e 100644 --- a/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml +++ b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml @@ -20,7 +20,7 @@ interactions: cache-control: [no-cache] content-length: ['326'] content-type: [application/json; charset=utf-8] - date: ['Mon, 01 May 2017 23:13:21 GMT'] + date: ['Tue, 02 May 2017 18:16:09 GMT'] expires: ['-1'] pragma: [no-cache] strict-transport-security: [max-age=31536000; includeSubDomains] @@ -43,13 +43,13 @@ interactions: method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"0000b805-0000-0000-0000-5907c1110000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"fa364912921a4b5c84206c4380af3e46","dateCreated":"2017-05-01T23:13:23.9947901Z","provisioningState":"Succeeded"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"00007a03-0000-0000-0000-5908cceb0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"c56a9d85d19445db8be4236f26168205","dateCreated":"2017-05-02T18:16:11.361061Z","provisioningState":"Succeeded"}}'} headers: cache-control: [no-cache] - content-length: ['596'] + content-length: ['595'] content-type: [application/json; charset=utf-8] - date: ['Mon, 01 May 2017 23:13:22 GMT'] - etag: ['"0000b805-0000-0000-0000-5907c1110000"'] + date: ['Tue, 02 May 2017 18:16:12 GMT'] + etag: ['"00007a03-0000-0000-0000-5908cceb0000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -73,13 +73,13 @@ interactions: method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"0000b805-0000-0000-0000-5907c1110000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"fa364912921a4b5c84206c4380af3e46","dateCreated":"2017-05-01T23:13:23.9947901Z","provisioningState":"Succeeded"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"00007a03-0000-0000-0000-5908cceb0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"c56a9d85d19445db8be4236f26168205","dateCreated":"2017-05-02T18:16:11.361061Z","provisioningState":"Succeeded"}}'} headers: cache-control: [no-cache] - content-length: ['596'] + content-length: ['595'] content-type: [application/json; charset=utf-8] - date: ['Mon, 01 May 2017 23:13:24 GMT'] - etag: ['"0000b805-0000-0000-0000-5907c1110000"'] + date: ['Tue, 02 May 2017 18:16:13 GMT'] + etag: ['"00007a03-0000-0000-0000-5908cceb0000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -105,13 +105,13 @@ interactions: method: PATCH uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18 response: - body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"0000ba05-0000-0000-0000-5907c1140000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"fa364912921a4b5c84206c4380af3e46","dateCreated":"2017-05-01T23:13:23.9947901Z"}}'} + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00007c03-0000-0000-0000-5908ccef0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"c56a9d85d19445db8be4236f26168205","dateCreated":"2017-05-02T18:16:11.361061Z"}}'} headers: cache-control: [no-cache] - content-length: ['631'] + content-length: ['630'] content-type: [application/json; charset=utf-8] - date: ['Mon, 01 May 2017 23:13:26 GMT'] - etag: ['"0000ba05-0000-0000-0000-5907c1140000"'] + date: ['Tue, 02 May 2017 18:16:15 GMT'] + etag: ['"00007c03-0000-0000-0000-5908ccef0000"'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -119,7 +119,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-aspnet-version: [4.0.30319] - x-ms-ratelimit-remaining-subscription-writes: ['1198'] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-powered-by: [ASP.NET] status: {code: 200, message: OK} - request: @@ -138,12 +138,12 @@ interactions: method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/listKeys?api-version=2017-04-18 response: - body: {string: '{"key1":"a0575889d7534fa0a8750c2c05c7e9a1","key2":"5c9fd8926982491e99acb650a6eb2315"}'} + body: {string: '{"key1":"d29ffb312c8949e285e7f8b550b184db","key2":"ad0971db96c74b5fa792b498bad2363d"}'} headers: cache-control: [no-cache] content-length: ['85'] content-type: [application/json; charset=utf-8] - date: ['Mon, 01 May 2017 23:13:27 GMT'] + date: ['Tue, 02 May 2017 18:16:17 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -170,12 +170,12 @@ interactions: method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/regenerateKey?api-version=2017-04-18 response: - body: {string: '{"key1":"ee576aab47ef4800aa547f74e84bb47f","key2":"5c9fd8926982491e99acb650a6eb2315"}'} + body: {string: '{"key1":"ff544e6348384eb38ca3066e73a3ae6f","key2":"ad0971db96c74b5fa792b498bad2363d"}'} headers: cache-control: [no-cache] content-length: ['85'] content-type: [application/json; charset=utf-8] - date: ['Mon, 01 May 2017 23:13:28 GMT'] + date: ['Tue, 02 May 2017 18:16:19 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -201,12 +201,12 @@ interactions: method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts?api-version=2017-04-18 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"0000be05-0000-0000-0000-5907c1170000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"fa364912921a4b5c84206c4380af3e46","dateCreated":"2017-05-01T23:13:23.9947901Z"}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00008003-0000-0000-0000-5908ccf20000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"c56a9d85d19445db8be4236f26168205","dateCreated":"2017-05-02T18:16:11.361061Z"}}]}'} headers: cache-control: [no-cache] - content-length: ['643'] + content-length: ['642'] content-type: [application/json; charset=utf-8] - date: ['Mon, 01 May 2017 23:13:29 GMT'] + date: ['Tue, 02 May 2017 18:16:20 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -236,7 +236,7 @@ interactions: headers: cache-control: [no-cache] content-length: ['0'] - date: ['Mon, 01 May 2017 23:13:32 GMT'] + date: ['Tue, 02 May 2017 18:16:22 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-IIS/8.5] @@ -265,9 +265,9 @@ interactions: headers: cache-control: [no-cache] content-length: ['0'] - date: ['Mon, 01 May 2017 23:13:32 GMT'] + date: ['Tue, 02 May 2017 18:16:23 GMT'] expires: ['-1'] - location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkczREY5ODFEMTMyMDdCMkFGRUM5RjU5RUI2NjYwOUU4RkQ3RHwyNzAzMkVENUQ0QzE2RDgzLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkc0OTc2NzcxQUVFQjA5RjEwNTE4NDA0NUEyN0U5QzgxNEZCQXxGMUJCM0M4NENBODZDQjJGLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] pragma: [no-cache] retry-after: ['15'] strict-transport-security: [max-age=31536000; includeSubDomains] From 410e4909db77af81fa5b3ae518a3184a176a0675 Mon Sep 17 00:00:00 2001 From: kostenray Date: Tue, 2 May 2017 13:48:20 -0700 Subject: [PATCH 14/15] update the setup.py --- src/command_modules/azure-cli-cognitiveservices/setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-cognitiveservices/setup.py b/src/command_modules/azure-cli-cognitiveservices/setup.py index 1c7247c2ada..a88c70e75ef 100644 --- a/src/command_modules/azure-cli-cognitiveservices/setup.py +++ b/src/command_modules/azure-cli-cognitiveservices/setup.py @@ -13,6 +13,8 @@ logger.warn("Wheel is not available, disabling bdist_wheel hook") cmdclass = {} +VERSION = '0.1.0+dev' + # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers CLASSIFIERS = [ @@ -35,10 +37,12 @@ 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='azure-cli-cognitiveservices', - version='0.1.0', + version=VERSION, description='Microsoft Azure Command-Line Tools Cognitive Services Command Module', long_description=README, license='MIT', From 9065ccc2a77110e565fe89a7ab379c3528a2387e Mon Sep 17 00:00:00 2001 From: kostenray Date: Tue, 2 May 2017 13:52:05 -0700 Subject: [PATCH 15/15] update description of setup.py --- src/command_modules/azure-cli-cognitiveservices/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-cognitiveservices/setup.py b/src/command_modules/azure-cli-cognitiveservices/setup.py index a88c70e75ef..08543bb7e11 100644 --- a/src/command_modules/azure-cli-cognitiveservices/setup.py +++ b/src/command_modules/azure-cli-cognitiveservices/setup.py @@ -44,7 +44,7 @@ name='azure-cli-cognitiveservices', version=VERSION, description='Microsoft Azure Command-Line Tools Cognitive Services Command Module', - long_description=README, + long_description=README + '\n\n' + HISTORY, license='MIT', author='Microsoft Corporation', author_email='azpycli@microsoft.com',