Hello community, here is the log from the commit of package azure-cli-cosmosdb for openSUSE:Factory checked in at 2018-02-14 09:30:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/azure-cli-cosmosdb (Old) and /work/SRC/openSUSE:Factory/.azure-cli-cosmosdb.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "azure-cli-cosmosdb" Wed Feb 14 09:30:36 2018 rev:2 rq:574806 version:0.1.17 Changes: -------- --- /work/SRC/openSUSE:Factory/azure-cli-cosmosdb/azure-cli-cosmosdb.changes 2017-11-10 14:53:32.324451715 +0100 +++ /work/SRC/openSUSE:Factory/.azure-cli-cosmosdb.new/azure-cli-cosmosdb.changes 2018-02-14 09:30:41.481503394 +0100 @@ -1,0 +2,10 @@ +Wed Feb 7 15:55:34 UTC 2018 - adrian.glaub...@suse.com + +- New upstream release + + Version 0.1.17 + + For detailed information about changes see the + HISTORY.rst file provided with this package +- Install HISTORY.rst into doc directory +- Update Requires from setup.py + +------------------------------------------------------------------- Old: ---- azure-cli-cosmosdb-0.1.13.tar.gz New: ---- azure-cli-cosmosdb-0.1.17.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ azure-cli-cosmosdb.spec ++++++ --- /var/tmp/diff_new_pack.kQaMS3/_old 2018-02-14 09:30:42.337472377 +0100 +++ /var/tmp/diff_new_pack.kQaMS3/_new 2018-02-14 09:30:42.345472087 +0100 @@ -1,7 +1,7 @@ # # spec file for package azure-cli-cosmosdb # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -15,8 +15,9 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # + Name: azure-cli-cosmosdb -Version: 0.1.13 +Version: 0.1.17 Release: 0 Summary: Microsoft Azure CLI 'cosmosdb' Command Module License: MIT @@ -24,17 +25,17 @@ Url: https://github.com/Azure/azure-cli Source: https://files.pythonhosted.org/packages/source/a/azure-cli-cosmosdb/azure-cli-cosmosdb-%{version}.tar.gz Source1: LICENSE.txt -BuildRequires: python3-devel -BuildRequires: python3-setuptools -BuildRequires: unzip BuildRequires: azure-cli-command-modules-nspkg BuildRequires: azure-cli-nspkg BuildRequires: python3-azure-nspkg +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: unzip Requires: azure-cli-command-modules-nspkg +Requires: azure-cli-core Requires: azure-cli-nspkg +Requires: python3-azure-mgmt-cosmosdb >= 0.2.1 Requires: python3-azure-nspkg -Requires: python3-azure-mgmt-documentdb >= 0.1.3 -Requires: azure-cli-core Conflicts: azure-cli < 2.0.0 BuildArch: noarch @@ -63,7 +64,8 @@ %files %defattr(-,root,root,-) -%doc LICENSE.txt README.rst +%doc HISTORY.rst LICENSE.txt README.rst %{python3_sitelib}/azure/cli/command_modules/cosmosdb %{python3_sitelib}/azure_cli_cosmosdb-*.egg-info + %changelog ++++++ azure-cli-cosmosdb-0.1.13.tar.gz -> azure-cli-cosmosdb-0.1.17.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/HISTORY.rst new/azure-cli-cosmosdb-0.1.17/HISTORY.rst --- old/azure-cli-cosmosdb-0.1.13/HISTORY.rst 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/HISTORY.rst 2018-01-26 17:12:23.000000000 +0100 @@ -2,6 +2,23 @@ Release History =============== + +0.1.17 +++++++ +* Fix parameter description for failover policies. + +0.1.16 +++++++ +* Update for CLI core changes. + +0.1.15 +++++++ +* Use latest azure-mgmt-cosmosdb pypi package (0.2.1) + +0.1.14 +++++++ +* minor fixes + 0.1.13 (2017-09-22) +++++++++++++++++++ * minor fixes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/PKG-INFO new/azure-cli-cosmosdb-0.1.17/PKG-INFO --- old/azure-cli-cosmosdb-0.1.13/PKG-INFO 2017-09-23 01:48:04.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/PKG-INFO 2018-01-26 17:12:50.000000000 +0100 @@ -1,12 +1,11 @@ Metadata-Version: 1.1 Name: azure-cli-cosmosdb -Version: 0.1.13 +Version: 0.1.17 Summary: Microsoft Azure Command-Line Tools Cosmos DB Command Module Home-page: https://github.com/Azure/azure-cli Author: Microsoft Corporation Author-email: azpy...@microsoft.com License: MIT -Description-Content-Type: UNKNOWN Description: Microsoft Azure CLI 'cosmosdb' Command Module ============================================= @@ -20,6 +19,23 @@ Release History =============== + + 0.1.17 + ++++++ + * Fix parameter description for failover policies. + + 0.1.16 + ++++++ + * Update for CLI core changes. + + 0.1.15 + ++++++ + * Use latest azure-mgmt-cosmosdb pypi package (0.2.1) + + 0.1.14 + ++++++ + * minor fixes + 0.1.13 (2017-09-22) +++++++++++++++++++ * minor fixes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/__init__.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/__init__.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/__init__.py 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/__init__.py 2018-01-26 17:12:23.000000000 +0100 @@ -3,12 +3,44 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -import azure.cli.command_modules.cosmosdb._help # pylint: disable=unused-import +from knack.events import EVENT_INVOKER_PRE_PARSE_ARGS +from azure.cli.core import AzCommandsLoader -def load_params(_): - import azure.cli.command_modules.cosmosdb._params # pylint: disable=redefined-outer-name, unused-variable +from azure.cli.command_modules.cosmosdb._help import helps # pylint: disable=unused-import -def load_commands(): - import azure.cli.command_modules.cosmosdb.commands # pylint: disable=redefined-outer-name, unused-variable +def _documentdb_deprecate(_, args): + if args[0] == 'documentdb': + from azure.cli.core.util import CLIError + raise CLIError('All documentdb commands have been renamed to cosmosdb') + + +class CosmosDbCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azure.cli.command_modules.cosmosdb._client_factory import cf_cosmosdb_document + from azure.cli.command_modules.cosmosdb._command_type import CosmosDbCommandGroup + cosmosdb_custom = CliCommandType( + operations_tmpl='azure.cli.command_modules.cosmosdb.custom#{}', + client_factory=cf_cosmosdb_document) + + cli_ctx.register_event(EVENT_INVOKER_PRE_PARSE_ARGS, _documentdb_deprecate) + + super(CosmosDbCommandsLoader, self).__init__(cli_ctx=cli_ctx, + min_profile='2017-03-10-profile', + custom_command_type=cosmosdb_custom, + command_group_cls=CosmosDbCommandGroup) + + def load_command_table(self, args): + from azure.cli.command_modules.cosmosdb.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azure.cli.command_modules.cosmosdb._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = CosmosDbCommandsLoader diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_client_factory.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_client_factory.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_client_factory.py 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_client_factory.py 2018-01-26 17:12:23.000000000 +0100 @@ -4,11 +4,15 @@ # -------------------------------------------------------------------------------------------- import os -import azure.cli.core.azlogging as azlogging -from azure.cli.core.util import CLIError + +from knack.log import get_logger +from knack.util import CLIError + from azure.cli.core import __version__ as core_version -logger = azlogging.get_az_logger(__name__) + +logger = get_logger(__name__) + NO_CREDENTIALS_ERROR_MESSAGE = """ No credentials specified to access Cosmos DB service. Please provide any of the following: @@ -39,7 +43,7 @@ return None -def get_document_client_factory(kwargs): +def cf_cosmosdb_document(cli_ctx, kwargs): from pydocumentdb import document_client service_type = document_client.DocumentClient @@ -52,7 +56,7 @@ if name and resource_group and not key: # if resource group name is provided find key - keys = cf_documentdb().database_accounts.list_keys(resource_group, name) + keys = cf_cosmosdb(cli_ctx).database_accounts.list_keys(resource_group, name) key = keys.primary_master_key url_connection = _get_url_connection(url_connection, name) @@ -72,7 +76,11 @@ return client -def cf_documentdb(**_): +def cf_cosmosdb(cli_ctx, **_): from azure.cli.core.commands.client_factory import get_mgmt_service_client - from azure.mgmt.documentdb import DocumentDB - return get_mgmt_service_client(DocumentDB) + from azure.mgmt.cosmosdb import CosmosDB + return get_mgmt_service_client(cli_ctx, CosmosDB) + + +def cf_db_accounts(cli_ctx, _): + return cf_cosmosdb(cli_ctx).database_accounts diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_command_type.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_command_type.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_command_type.py 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_command_type.py 2018-01-26 17:12:23.000000000 +0100 @@ -3,41 +3,54 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.cli.core.commands import create_command, command_table +from azure.cli.core.commands import AzCommandGroup -def cli_cosmosdb_data_plane_command(name, - operation, client_factory, transform=None, - table_transformer=None, exception_handler=None): - """Registers an Azure CLI Cosmos DB Data Plane command. These commands always include the - parameters which can be used to obtain a cosmosdb client.""" - - if not exception_handler: - from ._exception_handler import generic_exception_handler - exception_handler = generic_exception_handler - - command = create_command(__name__, name, operation, transform, table_transformer, - client_factory, exception_handler=exception_handler) - - # add parameters required to create a cosmosdb client - group_name = 'Cosmos DB Account' - - command.add_argument('db_resource_group_name', '--resource-group-name', '-g', - arg_group=group_name, - help='name of the resource group. Must be used in conjunction with ' - 'cosmosdb account name.') - command.add_argument('db_account_name', '--name', '-n', arg_group=group_name, - help='Cosmos DB account name. Must be used in conjunction with ' - 'either name of the resource group or cosmosdb account key.') - - command.add_argument('db_account_key', '--key', required=False, default=None, - arg_group=group_name, - help='Cosmos DB account key. Must be used in conjunction with cosmosdb ' - 'account name or url-connection.') - - command.add_argument('db_url_connection', '--url-connection', required=False, default=None, - arg_group=group_name, - help='Cosmos DB account url connection. Must be used in conjunction with ' - 'cosmosdb account key.') +class CosmosDbCommandGroup(AzCommandGroup): - command_table[command.name] = command + def _create_cosmosdb_command(self, name, method_name=None, command_type_name=None, **kwargs): + """Registers an Azure CLI Cosmos DB Data Plane command. These commands always include the + parameters which can be used to obtain a cosmosdb client.""" + + merged_kwargs = self._flatten_kwargs(kwargs, command_type_name) + if 'exception_handler' not in merged_kwargs: + from ._exception_handler import generic_exception_handler + merged_kwargs['exception_handler'] = generic_exception_handler + if command_type_name == 'command_type': + command_name = self.command(name, method_name, **merged_kwargs) + else: + command_name = self.custom_command(name, method_name, **merged_kwargs) + + command = self.command_loader.command_table[command_name] + + # add parameters required to create a cosmosdb client + group_name = 'Cosmos DB Account' + command.add_argument('db_resource_group_name', '--resource-group-name', '-g', + arg_group=group_name, + help='name of the resource group. Must be used in conjunction with ' + 'cosmosdb account name.') + command.add_argument('db_account_name', '--name', '-n', arg_group=group_name, + help='Cosmos DB account name. Must be used in conjunction with ' + 'either name of the resource group or cosmosdb account key.') + + command.add_argument('db_account_key', '--key', required=False, default=None, + arg_group=group_name, + help='Cosmos DB account key. Must be used in conjunction with cosmosdb ' + 'account name or url-connection.') + + command.add_argument('db_url_connection', '--url-connection', required=False, default=None, + arg_group=group_name, + help='Cosmos DB account url connection. Must be used in conjunction with ' + 'cosmosdb account key.') + + def cosmosdb_command(self, name, method_name=None, command_type=None, **kwargs): + command_type_name = 'command_type' + if command_type: + kwargs[command_type_name] = command_type + self._create_cosmosdb_command(name, method_name, command_type_name, **kwargs) + + def cosmosdb_custom(self, name, method_name=None, command_type=None, **kwargs): + command_type_name = 'custom_command_type' + if command_type: + kwargs[command_type_name] = command_type + self._create_cosmosdb_command(name, method_name, command_type_name, **kwargs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_exception_handler.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_exception_handler.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_exception_handler.py 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_exception_handler.py 2018-01-26 17:12:23.000000000 +0100 @@ -4,10 +4,12 @@ # -------------------------------------------------------------------------------------------- import json -from azure.cli.core.util import CLIError -import azure.cli.core.azlogging as azlogging -logger = azlogging.get_az_logger(__name__) +from knack.log import get_logger +from knack.util import CLIError + + +logger = get_logger(__name__) def duplicate_resource_exception_handler(ex): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_help.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_help.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_help.py 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_help.py 2018-01-26 17:12:23.000000000 +0100 @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.cli.core.help_files import helps +from knack.help_files import helps helps['cosmosdb'] = """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_params.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_params.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_params.py 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_params.py 2018-01-26 17:12:23.000000000 +0100 @@ -5,90 +5,44 @@ # pylint: disable=line-too-long from argcomplete.completers import FilesCompleter -from azure.cli.core.commands.parameters import ( - get_resource_name_completion_list, - enum_choice_list, - name_type, - ignore_type) +from azure.cli.core.commands.parameters import ( + get_resource_name_completion_list, name_type, get_enum_type, get_three_state_flag) from azure.cli.core.util import shell_safe_json_parse -from azure.mgmt.documentdb.models.document_db_enums import KeyKind -from azure.mgmt.documentdb.models.document_db_enums import DefaultConsistencyLevel -from azure.mgmt.documentdb.models.document_db_enums import DatabaseAccountKind -from azure.mgmt.documentdb.models.failover_policy import FailoverPolicy -from azure.mgmt.documentdb.models.location import Location -from azure.cli.core.commands import register_cli_argument, CliArgumentType - - -def validate_failover_policies(ns): - """ Extracts multiple space-separated failoverPolicies in regionName=failoverPriority format """ - fp_dict = [] - for item in ns.failover_policies: - comps = item.split('=', 1) - fp_dict.append(FailoverPolicy(comps[0], int(comps[1]))) - ns.failover_policies = fp_dict - - -def validate_locations(ns): - """ Extracts multiple space-separated locations in regionName=failoverPriority format """ - if ns.locations is None: - ns.locations = [] - return - loc_dict = [] - for item in ns.locations: - comps = item.split('=', 1) - loc_dict.append(Location(location_name=comps[0], failover_priority=int(comps[1]))) - ns.locations = loc_dict - - -def validate_ip_range_filter(ns): - if ns.ip_range_filter: - ns.ip_range_filter = ",".join(ns.ip_range_filter) - - -register_cli_argument('cosmosdb', 'account_name', arg_type=name_type, help='Name of the Cosmos DB database account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part="name") - -register_cli_argument('cosmosdb regenerate-key', 'key_kind', **enum_choice_list(KeyKind)) -register_cli_argument('cosmosdb failover-priority-change', 'failover_policies', validator=validate_failover_policies, help="space separated failover policies in 'regionName=failoverPriority' format. E.g \"East US\"=0 \"West US\"=1", nargs='+') -register_cli_argument('cosmosdb create', 'account_name', completer=None) -register_cli_argument('cosmosdb create', 'resource_group_name', help="name of the resource group") -register_cli_argument('cosmosdb create', 'resource_group_location', ignore_type) -register_cli_argument('cosmosdb create', 'locations', validator=validate_locations, help="space separated locations in 'regionName=failoverPriority' format. E.g \"East US\"=0 \"West US\"=1. Failover priority values are 0 for write regions and greater than 0 for read regions. A failover priority value must be unique and less than the total number of regions. Default: single region account in the location of the specified resource group.", nargs='+') -register_cli_argument('cosmosdb create', 'default_consistency_level', help="default consistency level of the Cosmos DB database account", **enum_choice_list(DefaultConsistencyLevel)) -register_cli_argument('cosmosdb create', 'max_staleness_prefix', help="when used with Bounded Staleness consistency, this value represents the number of stale requests tolerated. Accepted range for this value is 1 - 2,147,483,647", type=int) -register_cli_argument('cosmosdb create', 'max_interval', help="when used with Bounded Staleness consistency, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 1 - 100", type=int) -register_cli_argument('cosmosdb create', 'ip_range_filter', validator=validate_ip_range_filter, help="firewall support. Specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account. IP addresses/ranges must be comma separated and must not contain any spaces", nargs='+') -register_cli_argument('cosmosdb create', 'kind', help='The type of Cosmos DB database account to create', **enum_choice_list(DatabaseAccountKind)) -register_cli_argument('cosmosdb create', 'enable_automatic_failover', help='Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account.', type=bool) - -register_cli_argument('cosmosdb update', 'account_name', completer=None) -register_cli_argument('cosmosdb update', 'resource_group_name', help="name of the resource group") -register_cli_argument('cosmosdb update', 'locations', validator=validate_locations, help="space separated locations in 'regionName=failoverPriority' format. E.g \"East US\"=0. Failover priority values are 0 for write regions and greater than 0 for read regions. A failover priority value must be unique and less than the total number of regions.", nargs='+') -register_cli_argument('cosmosdb update', 'default_consistency_level', help="default consistency level of the Cosmos DB database account", **enum_choice_list(DefaultConsistencyLevel)) -register_cli_argument('cosmosdb update', 'max_staleness_prefix', help="when used with Bounded Staleness consistency, this value represents the number of stale requests tolerated. Accepted range for this value is 1 - 2,147,483,647", type=int) -register_cli_argument('cosmosdb update', 'max_interval', help="when used with Bounded Staleness consistency, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 1 - 100", type=int) -register_cli_argument('cosmosdb update', 'ip_range_filter', validator=validate_ip_range_filter, help="firewall support. Specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account. IP addresses/ranges must be comma separated and must not contain any spaces", nargs='+') -register_cli_argument('cosmosdb update', 'enable_automatic_failover', help='Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account.', type=bool) - -# database id -database_id = CliArgumentType(options_list=('--db-name', '-d'), help='Database Name') -register_cli_argument('cosmosdb database', 'database_id', database_id) -register_cli_argument('cosmosdb collection', 'database_id', database_id) - -register_cli_argument('cosmosdb collection', 'collection_id', - options_list=('--collection-name', '-c'), help='Collection Name') - -register_cli_argument('cosmosdb collection', 'throughput', - options_list=('--throughput'), help='Offer Throughput', type=int) - -register_cli_argument('cosmosdb collection', 'partition_key_path', - options_list=('--partition-key-path'), - help='Partition Key Path, e.g., \'/properties/name\'') - -register_cli_argument('cosmosdb collection', 'indexing_policy', - options_list=('--indexing-policy'), - help='Indexing Policy, you can enter it as a string or as a file, e.g., --indexing-policy @policy-file.json)', - type=shell_safe_json_parse, completer=FilesCompleter()) +from azure.cli.command_modules.cosmosdb._validators import ( + validate_locations, validate_ip_range_filter, validate_failover_policies) + + +def load_arguments(self, _): + + from azure.mgmt.cosmosdb.models.cosmos_db_enums import KeyKind, DefaultConsistencyLevel, DatabaseAccountKind -register_cli_argument('cosmosdb collection', 'default_ttl', help='Default TTL', type=int) + with self.argument_context('cosmosdb') as c: + c.argument('account_name', arg_type=name_type, help='Name of the Cosmos DB database account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part='name') + c.argument('database_id', options_list=['--db-name', '-d'], help='Database Name') + + for scope in ['cosmosdb create', 'cosmosdb update']: + with self.argument_context(scope) as c: + c.argument('account_name', completer=None) + c.ignore('resource_group_location') + c.argument('locations', nargs='+', validator=validate_locations, help="space separated locations in 'regionName=failoverPriority' format. E.g eastus=0 westus=1. Failover priority values are 0 for write regions and greater than 0 for read regions. A failover priority value must be unique and less than the total number of regions. Default: single region account in the location of the specified resource group.") + c.argument('default_consistency_level', arg_type=get_enum_type(DefaultConsistencyLevel), help="default consistency level of the Cosmos DB database account") + c.argument('max_staleness_prefix', type=int, help="when used with Bounded Staleness consistency, this value represents the number of stale requests tolerated. Accepted range for this value is 1 - 2,147,483,647") + c.argument('max_interval', type=int, help="when used with Bounded Staleness consistency, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 1 - 100") + c.argument('ip_range_filter', nargs='+', validator=validate_ip_range_filter, help="firewall support. Specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account. IP addresses/ranges must be comma separated and must not contain any spaces") + c.argument('kind', arg_type=get_enum_type(DatabaseAccountKind), help='The type of Cosmos DB database account to create') + c.argument('enable_automatic_failover', arg_type=get_three_state_flag(), help='Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account.') + + with self.argument_context('cosmosdb regenerate-key') as c: + c.argument('key_kind', arg_type=get_enum_type(KeyKind)) + + with self.argument_context('cosmosdb failover-priority-change') as c: + c.argument('failover_policies', validator=validate_failover_policies, help="space separated failover policies in 'regionName=failoverPriority' format. E.g eastus=0 westus=1", nargs='+') + + with self.argument_context('cosmosdb collection') as c: + c.argument('collection_id', options_list=['--collection-name', '-c'], help='Collection Name') + c.argument('throughput', type=int, help='Offer Throughput') + c.argument('partition_key_path', help='Partition Key Path, e.g., \'/properties/name\'') + c.argument('indexing_policy', type=shell_safe_json_parse, completer=FilesCompleter(), help='Indexing Policy, you can enter it as a string or as a file, e.g., --indexing-policy @policy-file.json)') + c.argument('default_ttl', type=int, help='Default TTL') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_validators.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_validators.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/_validators.py 1970-01-01 01:00:00.000000000 +0100 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/_validators.py 2018-01-26 17:12:23.000000000 +0100 @@ -0,0 +1,32 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def validate_failover_policies(ns): + """ Extracts multiple space-separated failoverPolicies in regionName=failoverPriority format """ + from azure.mgmt.cosmosdb.models.failover_policy import FailoverPolicy + fp_dict = [] + for item in ns.failover_policies: + comps = item.split('=', 1) + fp_dict.append(FailoverPolicy(comps[0], int(comps[1]))) + ns.failover_policies = fp_dict + + +def validate_locations(ns): + """ Extracts multiple space-separated locations in regionName=failoverPriority format """ + from azure.mgmt.cosmosdb.models.location import Location + if ns.locations is None: + ns.locations = [] + return + loc_dict = [] + for item in ns.locations: + comps = item.split('=', 1) + loc_dict.append(Location(location_name=comps[0], failover_priority=int(comps[1]))) + ns.locations = loc_dict + + +def validate_ip_range_filter(ns): + if ns.ip_range_filter: + ns.ip_range_filter = ",".join(ns.ip_range_filter) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/commands.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/commands.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/commands.py 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/commands.py 2018-01-26 17:12:23.000000000 +0100 @@ -5,50 +5,43 @@ # pylint: disable=line-too-long -from azure.cli.core.application import APPLICATION -from azure.cli.core.commands import cli_command -from azure.cli.core.profiles import supported_api_version, PROFILE_TYPE -from azure.cli.command_modules.cosmosdb._client_factory import (cf_documentdb) -from ._client_factory import get_document_client_factory -from ._command_type import cli_cosmosdb_data_plane_command - -if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'): - mgmt_path = 'azure.mgmt.documentdb.operations.database_accounts_operations#' - custome_path = 'azure.cli.command_modules.cosmosdb.custom#' - - def deprecate(argv): - if argv[0] == 'documentdb': - from azure.cli.core.util import CLIError - raise CLIError('All documentdb commands have been renamed to cosmosdb') - - APPLICATION.register(APPLICATION.COMMAND_PARSER_PARSING, deprecate) - - def db_accounts_factory(_): - return cf_documentdb().database_accounts - - cli_command(__name__, 'cosmosdb show', mgmt_path + 'DatabaseAccountsOperations.get', db_accounts_factory) - cli_command(__name__, 'cosmosdb list-keys', mgmt_path + 'DatabaseAccountsOperations.list_keys', db_accounts_factory) - cli_command(__name__, 'cosmosdb list-read-only-keys', mgmt_path + 'DatabaseAccountsOperations.list_read_only_keys', db_accounts_factory) - cli_command(__name__, 'cosmosdb list-connection-strings', mgmt_path + 'DatabaseAccountsOperations.list_connection_strings', db_accounts_factory) - cli_command(__name__, 'cosmosdb regenerate-key', mgmt_path + 'DatabaseAccountsOperations.regenerate_key', db_accounts_factory) - cli_command(__name__, 'cosmosdb check-name-exists', mgmt_path + 'DatabaseAccountsOperations.check_name_exists', db_accounts_factory) - cli_command(__name__, 'cosmosdb delete', mgmt_path + 'DatabaseAccountsOperations.delete', db_accounts_factory) - cli_command(__name__, 'cosmosdb failover-priority-change', mgmt_path + 'DatabaseAccountsOperations.failover_priority_change', db_accounts_factory) - cli_command(__name__, 'cosmosdb create', custome_path + 'cli_cosmosdb_create', db_accounts_factory) - cli_command(__name__, 'cosmosdb update', custome_path + 'cli_cosmosdb_update', db_accounts_factory) - cli_command(__name__, 'cosmosdb list', custome_path + 'cli_cosmosdb_list', db_accounts_factory) +from azure.cli.core.commands import CliCommandType + +from azure.cli.command_modules.cosmosdb._client_factory import cf_db_accounts + + +def load_command_table(self, _): + + cosmosdb_sdk = CliCommandType( + operations_tmpl='azure.mgmt.cosmosdb.operations.database_accounts_operations#DatabaseAccountsOperations.{}', + client_factory=cf_db_accounts) + + with self.command_group('cosmosdb', cosmosdb_sdk, client_factory=cf_db_accounts) as g: + g.command('show', 'get') + g.command('list-keys', 'list_keys') + g.command('list-read-only-keys', 'list_read_only_keys') + g.command('list-connection-strings', 'list_connection_strings') + g.command('regenerate-key', 'regenerate_key') + g.command('check-name-exists', 'check_name_exists') + g.command('delete', 'delete') + g.command('failover-priority-change', 'failover_priority_change') + g.custom_command('create', 'cli_cosmosdb_create') + g.custom_command('update', 'cli_cosmosdb_update') + g.custom_command('list', 'cli_cosmosdb_list') # # database operations - cli_cosmosdb_data_plane_command('cosmosdb database show', custome_path + 'cli_cosmosdb_database_show', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb database list', custome_path + 'cli_cosmosdb_database_list', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb database exists', custome_path + 'cli_cosmosdb_database_exists', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb database create', custome_path + 'cli_cosmosdb_database_create', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb database delete', custome_path + 'cli_cosmosdb_database_delete', get_document_client_factory) + with self.command_group('cosmosdb database') as g: + g.cosmosdb_custom('show', 'cli_cosmosdb_database_show') + g.cosmosdb_custom('list', 'cli_cosmosdb_database_list') + g.cosmosdb_custom('exists', 'cli_cosmosdb_database_exists') + g.cosmosdb_custom('create', 'cli_cosmosdb_database_create') + g.cosmosdb_custom('delete', 'cli_cosmosdb_database_delete') # collection operations - cli_cosmosdb_data_plane_command('cosmosdb collection show', custome_path + 'cli_cosmosdb_collection_show', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb collection list', custome_path + 'cli_cosmosdb_collection_list', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb collection exists', custome_path + 'cli_cosmosdb_collection_exists', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb collection create', custome_path + 'cli_cosmosdb_collection_create', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb collection delete', custome_path + 'cli_cosmosdb_collection_delete', get_document_client_factory) - cli_cosmosdb_data_plane_command('cosmosdb collection update', custome_path + 'cli_cosmosdb_collection_update', get_document_client_factory) + with self.command_group('cosmosdb collection') as g: + g.cosmosdb_custom('show', 'cli_cosmosdb_collection_show') + g.cosmosdb_custom('list', 'cli_cosmosdb_collection_list') + g.cosmosdb_custom('exists', 'cli_cosmosdb_collection_exists') + g.cosmosdb_custom('create', 'cli_cosmosdb_collection_create') + g.cosmosdb_custom('delete', 'cli_cosmosdb_collection_delete') + g.cosmosdb_custom('update', 'cli_cosmosdb_collection_update') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/custom.py new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/custom.py --- old/azure-cli-cosmosdb-0.1.13/azure/cli/command_modules/cosmosdb/custom.py 2017-09-23 01:47:00.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure/cli/command_modules/cosmosdb/custom.py 2018-01-26 17:12:23.000000000 +0100 @@ -3,16 +3,19 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.mgmt.documentdb.models import ( +from knack.log import get_logger +from knack.util import CLIError + +from azure.mgmt.cosmosdb.models import ( ConsistencyPolicy, DatabaseAccountCreateUpdateParameters, Location ) -from azure.mgmt.documentdb.models.document_db_enums import DatabaseAccountKind -from azure.cli.core.util import CLIError -import azure.cli.core.azlogging as azlogging +from azure.mgmt.cosmosdb.models.cosmos_db_enums import DatabaseAccountKind + + +logger = get_logger(__name__) -logger = azlogging.get_az_logger(__name__) DEFAULT_INDEXING_POLICY = """{ "indexingMode": "consistent", @@ -37,7 +40,7 @@ }""" -def cli_cosmosdb_create(client, +def cli_cosmosdb_create(cmd, client, resource_group_name, account_name, locations=None, @@ -56,7 +59,7 @@ from azure.mgmt.resource import ResourceManagementClient from azure.cli.core.commands.client_factory import get_mgmt_service_client - resource_client = get_mgmt_service_client(ResourceManagementClient) + resource_client = get_mgmt_service_client(cmd.cli_ctx, ResourceManagementClient) rg = resource_client.resource_groups.get(resource_group_name) resource_group_location = rg.location # pylint: disable=no-member diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure_cli_cosmosdb.egg-info/PKG-INFO new/azure-cli-cosmosdb-0.1.17/azure_cli_cosmosdb.egg-info/PKG-INFO --- old/azure-cli-cosmosdb-0.1.13/azure_cli_cosmosdb.egg-info/PKG-INFO 2017-09-23 01:48:04.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure_cli_cosmosdb.egg-info/PKG-INFO 2018-01-26 17:12:50.000000000 +0100 @@ -1,12 +1,11 @@ Metadata-Version: 1.1 Name: azure-cli-cosmosdb -Version: 0.1.13 +Version: 0.1.17 Summary: Microsoft Azure Command-Line Tools Cosmos DB Command Module Home-page: https://github.com/Azure/azure-cli Author: Microsoft Corporation Author-email: azpy...@microsoft.com License: MIT -Description-Content-Type: UNKNOWN Description: Microsoft Azure CLI 'cosmosdb' Command Module ============================================= @@ -20,6 +19,23 @@ Release History =============== + + 0.1.17 + ++++++ + * Fix parameter description for failover policies. + + 0.1.16 + ++++++ + * Update for CLI core changes. + + 0.1.15 + ++++++ + * Use latest azure-mgmt-cosmosdb pypi package (0.2.1) + + 0.1.14 + ++++++ + * minor fixes + 0.1.13 (2017-09-22) +++++++++++++++++++ * minor fixes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure_cli_cosmosdb.egg-info/SOURCES.txt new/azure-cli-cosmosdb-0.1.17/azure_cli_cosmosdb.egg-info/SOURCES.txt --- old/azure-cli-cosmosdb-0.1.13/azure_cli_cosmosdb.egg-info/SOURCES.txt 2017-09-23 01:48:04.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure_cli_cosmosdb.egg-info/SOURCES.txt 2018-01-26 17:12:50.000000000 +0100 @@ -12,6 +12,7 @@ azure/cli/command_modules/cosmosdb/_exception_handler.py azure/cli/command_modules/cosmosdb/_help.py azure/cli/command_modules/cosmosdb/_params.py +azure/cli/command_modules/cosmosdb/_validators.py azure/cli/command_modules/cosmosdb/commands.py azure/cli/command_modules/cosmosdb/custom.py azure_cli_cosmosdb.egg-info/PKG-INFO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/azure_cli_cosmosdb.egg-info/requires.txt new/azure-cli-cosmosdb-0.1.17/azure_cli_cosmosdb.egg-info/requires.txt --- old/azure-cli-cosmosdb-0.1.13/azure_cli_cosmosdb.egg-info/requires.txt 2017-09-23 01:48:04.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/azure_cli_cosmosdb.egg-info/requires.txt 2018-01-26 17:12:50.000000000 +0100 @@ -1,4 +1,3 @@ -azure-mgmt-documentdb==0.1.3 +azure-mgmt-cosmosdb==0.2.1 azure-cli-core pydocumentdb>=2.0.1 -azure-cli-command-modules-nspkg>=2.0.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.1.13/setup.py new/azure-cli-cosmosdb-0.1.17/setup.py --- old/azure-cli-cosmosdb-0.1.13/setup.py 2017-09-23 01:48:03.000000000 +0200 +++ new/azure-cli-cosmosdb-0.1.17/setup.py 2018-01-26 17:12:23.000000000 +0100 @@ -16,7 +16,7 @@ cmdclass = {} -VERSION = "0.1.13" +VERSION = "0.1.17" # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers CLASSIFIERS = [ @@ -34,7 +34,7 @@ DEPENDENCIES = [ - 'azure-mgmt-documentdb==0.1.3', + 'azure-mgmt-cosmosdb==0.2.1', 'azure-cli-core', 'pydocumentdb>=2.0.1' ]