Hello community, here is the log from the commit of package azure-cli-cosmosdb for openSUSE:Factory checked in at 2019-10-31 18:15:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/azure-cli-cosmosdb (Old) and /work/SRC/openSUSE:Factory/.azure-cli-cosmosdb.new.2990 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "azure-cli-cosmosdb" Thu Oct 31 18:15:47 2019 rev:7 rq:742684 version:0.2.11 Changes: -------- --- /work/SRC/openSUSE:Factory/azure-cli-cosmosdb/azure-cli-cosmosdb.changes 2019-06-05 11:42:50.203045949 +0200 +++ /work/SRC/openSUSE:Factory/.azure-cli-cosmosdb.new.2990/azure-cli-cosmosdb.changes 2019-10-31 18:15:50.714047157 +0100 @@ -1,0 +2,9 @@ +Thu Oct 24 12:09:49 UTC 2019 - John Paul Adrian Glaubitz <[email protected]> + +- New upstream release + + Version 0.2.11 + + For detailed information about changes see the + HISTORY.txt file provided with this package +- Update Requires from setup.py + +------------------------------------------------------------------- Old: ---- azure-cli-cosmosdb-0.2.7.tar.gz New: ---- azure-cli-cosmosdb-0.2.11.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ azure-cli-cosmosdb.spec ++++++ --- /var/tmp/diff_new_pack.iSYGNV/_old 2019-10-31 18:15:51.366047831 +0100 +++ /var/tmp/diff_new_pack.iSYGNV/_new 2019-10-31 18:15:51.366047831 +0100 @@ -17,7 +17,7 @@ Name: azure-cli-cosmosdb -Version: 0.2.7 +Version: 0.2.11 Release: 0 Summary: Microsoft Azure CLI 'cosmosdb' Command Module License: MIT @@ -33,9 +33,9 @@ Requires: azure-cli-command-modules-nspkg Requires: azure-cli-core Requires: azure-cli-nspkg -Requires: python3-azure-mgmt-cosmosdb >= 0.5.2 +Requires: python-azure-cosmos >= 3.0.2 +Requires: python3-azure-mgmt-cosmosdb >= 0.6.1 Requires: python3-azure-nspkg >= 3.0.0 -Requires: python3-pydocumentdb >= 2.0.1 Conflicts: azure-cli < 2.0.0 BuildArch: noarch ++++++ azure-cli-cosmosdb-0.2.7.tar.gz -> azure-cli-cosmosdb-0.2.11.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/HISTORY.rst new/azure-cli-cosmosdb-0.2.11/HISTORY.rst --- old/azure-cli-cosmosdb-0.2.7/HISTORY.rst 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/HISTORY.rst 2019-06-13 23:17:46.000000000 +0200 @@ -3,6 +3,23 @@ Release History =============== +0.2.11 +++++++ +* Added command `keys list` and deprecated `list-keys`. +* `cosmsodb create/update`: Added new format for --location to allow setting "isZoneRedundant" property. Deprecated old format. + +0.2.10 +++++++ +* Minor fixes. + +0.2.9 ++++++ +* Introducing support for --enable-multiple-write-locations on account update + +0.2.8 ++++++ +* Introduce `network-rule` subgroup with commands `add`, `remove`, and `list` for managing VNET rules of a Cosmos DB account + 0.2.7 +++++ * Added support for creating database with shared throughput diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/PKG-INFO new/azure-cli-cosmosdb-0.2.11/PKG-INFO --- old/azure-cli-cosmosdb-0.2.7/PKG-INFO 2019-01-11 05:42:28.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/PKG-INFO 2019-06-13 23:18:20.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: azure-cli-cosmosdb -Version: 0.2.7 +Version: 0.2.11 Summary: Microsoft Azure Command-Line Tools Cosmos DB Command Module Home-page: https://github.com/Azure/azure-cli Author: Microsoft Corporation @@ -20,6 +20,23 @@ Release History =============== + 0.2.11 + ++++++ + * Added command `keys list` and deprecated `list-keys`. + * `cosmsodb create/update`: Added new format for --location to allow setting "isZoneRedundant" property. Deprecated old format. + + 0.2.10 + ++++++ + * Minor fixes. + + 0.2.9 + +++++ + * Introducing support for --enable-multiple-write-locations on account update + + 0.2.8 + +++++ + * Introduce `network-rule` subgroup with commands `add`, `remove`, and `list` for managing VNET rules of a Cosmos DB account + 0.2.7 +++++ * Added support for creating database with shared throughput diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/__init__.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/__init__.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/__init__.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/__init__.py 2019-06-13 23:17:46.000000000 +0200 @@ -22,6 +22,7 @@ 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 + from azure.cli.core.profiles import ResourceType cosmosdb_custom = CliCommandType( operations_tmpl='azure.cli.command_modules.cosmosdb.custom#{}', client_factory=cf_cosmosdb_document) @@ -29,7 +30,7 @@ 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', + resource_type=ResourceType.MGMT_COSMOSDB, custom_command_type=cosmosdb_custom, command_group_cls=CosmosDbCommandGroup) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_client_factory.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_client_factory.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_client_factory.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_client_factory.py 2019-06-13 23:17:46.000000000 +0200 @@ -35,8 +35,8 @@ def cf_cosmosdb_document(cli_ctx, kwargs): - from pydocumentdb import document_client - service_type = document_client.DocumentClient + from azure.cosmos import cosmos_client + service_type = cosmos_client.CosmosClient logger.debug('Getting data service client service_type=%s', service_type.__name__) try: @@ -60,7 +60,7 @@ if not key and not url_connection: raise CLIError(MISSING_CREDENTIALS_ERROR_MESSAGE) auth = {'masterKey': key} - client = document_client.DocumentClient(url_connection=url_connection, auth=auth) + client = cosmos_client.CosmosClient(url_connection=url_connection, auth=auth) except Exception as ex: if isinstance(ex, CLIError): raise ex diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_command_type.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_command_type.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_command_type.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_command_type.py 2019-06-13 23:17:46.000000000 +0200 @@ -11,7 +11,6 @@ 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_exception_handler.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_exception_handler.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_exception_handler.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_exception_handler.py 2019-06-13 23:17:46.000000000 +0200 @@ -14,7 +14,7 @@ def duplicate_resource_exception_handler(ex): # wraps DocumentDB 409 error in CLIError - from pydocumentdb.errors import HTTPFailure + from azure.cosmos.errors import HTTPFailure if isinstance(ex, HTTPFailure) and ex.status_code == 409: raise CLIError( 'Operation Failed: Resource Already Exists') @@ -23,7 +23,7 @@ def resource_not_found_exception_handler(ex): # wraps DocumentDB 404 error in CLIError - from pydocumentdb.errors import HTTPFailure + from azure.cosmos.errors import HTTPFailure if isinstance(ex, HTTPFailure) and ex.status_code == 404: raise CLIError('Operation Failed: Resource Not Found') raise ex @@ -31,7 +31,7 @@ def invalid_arg_found_exception_handler(ex): # wraps DocumentDB 400 error in CLIError - from pydocumentdb.errors import HTTPFailure + from azure.cosmos.errors import HTTPFailure if isinstance(ex, HTTPFailure) and ex.status_code == 400: cli_error = None try: @@ -53,7 +53,7 @@ def unknown_server_failure_exception_handler(ex): # wraps unknown documentdb error in CLIError - from pydocumentdb.errors import HTTPFailure + from azure.cosmos.errors import HTTPFailure if isinstance(ex, HTTPFailure): raise CLIError('Operation Failed: {}'.format(str(ex))) raise ex diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_format.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_format.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_format.py 1970-01-01 01:00:00.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_format.py 2019-06-13 23:17:46.000000000 +0200 @@ -0,0 +1,55 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from collections import OrderedDict + + +def list_database_output(result): + table = [] + for item in result: + table.append(database_output(item)) + return table + + +def database_output(result): + result = OrderedDict([('Database Id', result['id']), + ('_colls', result['_colls']), + ('_etag', result['_etag']), + ('_rid', result['_rid']), + ('_self', result['_self']), + ('_ts', result['_ts']), + ('_users', result['_users'])]) + return result + + +def list_collection_output(result): + table = [] + for item in result: + table.append(collection_output_helper(item)) + return table + + +def collection_output(result): + return collection_output_helper(result['collection']) + + +def collection_output_helper(result): + result = OrderedDict([('Collection Id', result['id']), + ('_conflicts', result['_conflicts']), + ('_docs', result['_docs']), + ('_etag', result['_etag']), + ('_rid', result['_rid']), + ('_self', result['_self']), + ('_sprocs', result['_sprocs']), + ('_triggers', result['_triggers']), + ('_ts', result['_ts'])]) + return result + + +def list_connection_strings_output(result): + table = [] + for item in result['connectionStrings']: + table.append(item) + return table diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_help.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_help.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_help.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_help.py 2019-06-13 23:17:46.000000000 +0200 @@ -4,75 +4,199 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from knack.help_files import helps - +from knack.help_files import helps # pylint: disable=unused-import +# pylint: disable=line-too-long, too-many-lines helps['cosmosdb'] = """ - type: group - short-summary: Manage Azure Cosmos DB database accounts. +type: group +short-summary: Manage Azure Cosmos DB database accounts. """ -helps['cosmosdb database'] = """ - type: group - short-summary: Manage Azure Cosmos DB databases. +helps['cosmosdb check-name-exists'] = """ +type: command +short-summary: Checks if an Azure Cosmos DB account name exists. +examples: + - name: Checks if an Azure Cosmos DB account name exists. (autogenerated) + text: az cosmosdb check-name-exists --name MyCosmosDBDatabaseAccount + crafted: true """ helps['cosmosdb collection'] = """ - type: group - short-summary: Manage Azure Cosmos DB collections. +type: group +short-summary: Manage Azure Cosmos DB collections. """ -helps['cosmosdb check-name-exists'] = """ - type: command - short-summary: Checks if an Azure Cosmos DB account name exists. +helps['cosmosdb create'] = """ +type: command +short-summary: Creates a new Azure Cosmos DB database account. +parameters: + - name: --locations + short-summary: Add a location to the Cosmos DB database account + long-summary: | + Usage: --locations KEY=VALUE [KEY=VALUE ...] + Required Keys: regionName, failoverPriority + Optional Key: isZoneRedundant + Default: single region account in the location of the specified resource group. + 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. + Multiple locations can be specified by using more than one `--locations` argument. +examples: + - name: Creates a new Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb create --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --subscription MySubscription + crafted: true + - name: Creates a new Azure Cosmos DB database account with two regions. UK South is zone redundant. + text: az cosmosdb create -n myaccount -g mygroup --locations regionName=eastus failoverPriority=0 isZoneRedundant=False --locations regionName=uksouth failoverPriority=1 isZoneRedundant=True --enable-multiple-write-locations """ -helps['cosmosdb create'] = """ - type: command - short-summary: Creates a new Azure Cosmos DB database account. +helps['cosmosdb database'] = """ +type: group +short-summary: Manage Azure Cosmos DB databases. +""" + +helps['cosmosdb database create'] = """ +type: command +short-summary: Creates an Azure Cosmos DB database +examples: + - name: Creates an Azure Cosmos DB database. + text: az cosmosdb database create --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --db-name MyDatabase + crafted: true +""" + +helps['cosmosdb database exists'] = """ +type: command +short-summary: Returns a boolean indicating whether the database exists +examples: + - name: Returns a boolean indicating whether the database exists. + text: az cosmosdb database exists --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --db-name MyDatabase + crafted: true +""" + +helps['cosmosdb database show'] = """ +type: command +short-summary: Shows an Azure Cosmos DB database +examples: + - name: Shows an Azure Cosmos DB database. + text: az cosmosdb database show --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --db-name MyDatabase + crafted: true +""" + +helps['cosmosdb database delete'] = """ +type: command +short-summary: Deletes an Azure Cosmos DB database +examples: + - name: Deletes an Azure Cosmos DB database. + text: az cosmosdb database delete --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --db-name MyDatabase + crafted: true +""" + +helps['cosmosdb database list'] = """ +type: command +short-summary: Lists all Azure Cosmos DB databases +examples: + - name: Lists all Azure Cosmos DB databases. + text: az cosmosdb database list --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup + crafted: true """ helps['cosmosdb delete'] = """ - type: command - short-summary: Deletes an Azure Cosmos DB database account. +type: command +short-summary: Deletes an Azure Cosmos DB database account. +examples: + - name: Deletes an Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb delete --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup + crafted: true """ helps['cosmosdb failover-priority-change'] = """ - type: command - short-summary: Changes the failover priority for the Azure Cosmos DB database account. +type: command +short-summary: Changes the failover priority for the Azure Cosmos DB database account. """ helps['cosmosdb list'] = """ - type: command - short-summary: List Azure Cosmos DB database accounts. +type: command +short-summary: List Azure Cosmos DB database accounts. """ helps['cosmosdb list-connection-strings'] = """ - type: command - short-summary: List the connection strings for a Azure Cosmos DB database account. +type: command +short-summary: List the connection strings for a Azure Cosmos DB database account. +examples: + - name: List the connection strings for a Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb list-connection-strings --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup + crafted: true """ helps['cosmosdb list-keys'] = """ - type: command - short-summary: List the access keys for a Azure Cosmos DB database account. +type: command +short-summary: List the access keys for a Azure Cosmos DB database account. +examples: + - name: List the access keys for a Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb list-keys --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --subscription MySubscription + crafted: true """ helps['cosmosdb list-read-only-keys'] = """ - type: command - short-summary: List the read-only access keys for a Azure Cosmos DB database account. +type: command +short-summary: List the read-only access keys for a Azure Cosmos DB database account. +examples: + - name: List the read-only access keys for a Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb list-read-only-keys --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup + crafted: true +""" + +helps['cosmosdb network-rule'] = """ +type: group +short-summary: Manage Azure Comsos DB network rules. """ helps['cosmosdb regenerate-key'] = """ - type: command - short-summary: Regenerate an access key for a Azure Cosmos DB database account. +type: command +short-summary: Regenerate an access key for a Azure Cosmos DB database account. +examples: + - name: Regenerate an access key for a Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb regenerate-key --key-kind primary --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup + crafted: true """ helps['cosmosdb show'] = """ - type: command - short-summary: Get the details of an Azure Cosmos DB database account. +type: command +short-summary: Get the details of an Azure Cosmos DB database account. +examples: + - name: Get the details of an Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb show --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup + crafted: true """ helps['cosmosdb update'] = """ - type: command - short-summary: Update an Azure Cosmos DB database account. +type: command +short-summary: Update an Azure Cosmos DB database account. +parameters: + - name: --locations + short-summary: Add a location to the Cosmos DB database account + long-summary: | + Usage: --locations KEY=VALUE [KEY=VALUE ...] + Required Keys: regionName, failoverPriority + Optional Key: isZoneRedundant + Default: single region account in the location of the specified resource group. + 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. + Multiple locations can be specified by using more than one `--locations` argument. +examples: + - name: Update an Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb update --capabilities EnableGremlin --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup + crafted: true + - name: Creates a new Azure Cosmos DB database account with two regions. UK South is zone redundant. + text: az cosmosdb update -n myaccount -g mygroup --locations regionName=eastus failoverPriority=0 isZoneRedundant=False --locations regionName=uksouth failoverPriority=1 isZoneRedundant=True --enable-multiple-write-locations +""" + +helps['cosmosdb keys'] = """ +type: group +short-summary: Manage Azure Comsos DB keys. +""" + +helps['cosmosdb keys list'] = """ +type: command +short-summary: List the access keys for a Azure Cosmos DB database account. +examples: + - name: List the access keys for a Azure Cosmos DB database account. (autogenerated) + text: az cosmosdb keys list --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --subscription MySubscription + crafted: true """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_params.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_params.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_params.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_params.py 2019-06-13 23:17:46.000000000 +0200 @@ -11,9 +11,12 @@ from azure.cli.core.util import shell_safe_json_parse from azure.cli.command_modules.cosmosdb._validators import ( - validate_locations, validate_ip_range_filter, validate_failover_policies, validate_capabilities, + validate_ip_range_filter, validate_failover_policies, validate_capabilities, validate_virtual_network_rules) +from azure.cli.command_modules.cosmosdb.actions import ( + CreateLocation) + def load_arguments(self, _): @@ -23,11 +26,13 @@ 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') + with self.argument_context('cosmosdb create') as c: + c.argument('account_name', completer=None) + 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('locations', nargs='+', action=CreateLocation) c.argument('tags', arg_type=tags_type) 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") @@ -46,6 +51,21 @@ 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 network-rule list') as c: + c.argument('account_name', id_part=None) + + with self.argument_context('cosmosdb keys list') as c: + c.argument('account_name', id_part=None) + + with self.argument_context('cosmosdb network-rule add') as c: + c.argument('subnet', help="Name or ID of the subnet") + c.argument('virtual_network', help="The name of the VNET, which must be provided in conjunction with the name of the subnet") + c.argument("ignore_missing_vnet_service_endpoint", arg_type=get_three_state_flag(), help="Create firewall rule before the virtual network has vnet service endpoint enabled.") + + with self.argument_context('cosmosdb network-rule remove') as c: + c.argument('subnet', help="Name or ID of the subnet") + c.argument('virtual_network', help="The name of the VNET, which must be provided in conjunction with the name of the subnet") + 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 (RU/s)') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_validators.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_validators.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/_validators.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/_validators.py 2019-06-13 23:17:46.000000000 +0200 @@ -14,19 +14,6 @@ ns.failover_policies = fp_dict -def validate_locations(ns): - """ Extracts multiple space-separated locations in regionName=failoverPriority format """ - from azure.mgmt.cosmosdb.models 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.2.7/azure/cli/command_modules/cosmosdb/actions.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/actions.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/actions.py 1970-01-01 01:00:00.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/actions.py 2019-06-13 23:17:46.000000000 +0200 @@ -0,0 +1,59 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import argparse + +from knack.log import get_logger +from knack.util import CLIError + +from azure.mgmt.cosmosdb.models import ( + Location +) + +logger = get_logger(__name__) + + +# pylint: disable=protected-access, too-few-public-methods +class CreateLocation(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + if namespace.locations is None: + namespace._deprecated_location_format = False + namespace.locations = [] + + if any("regionname" in s.lower() for s in values): + keys_found = set() + _name = "" + _failover = 0 + _is_zr = False + for item in values: + kvp = item.split('=', 1) + _key = kvp[0].lower() + if _key in keys_found: + raise CLIError('usage error: --locations [KEY=VALUE ...]') + keys_found.add(_key) + if _key == "regionname": + _name = kvp[1] + elif _key == "failoverpriority": + _failover = int(kvp[1]) + elif _key == "iszoneredundant": + _is_zr = kvp[1].lower() == "true" + else: + raise CLIError('usage error: --locations [KEY=VALUE ...]') + namespace.locations.append( + Location(location_name=_name, + failover_priority=_failover, + is_zone_redundant=_is_zr)) + else: + # pylint: disable=line-too-long + if not namespace._deprecated_location_format: + logger.warning('The regionName=failoverPriority method of specifying locations is deprecated. Use --locations KEY=VALUE [KEY=VALUE ...] to specify the regionName, failoverPriority, and isZoneRedundant properties of the location. Multiple locations can be specified by including more than one --locations argument.') + namespace._deprecated_location_format = True + + for item in values: + comps = item.split('=', 1) + namespace.locations.append( + Location(location_name=comps[0], + failover_priority=int(comps[1]), + is_zone_redundant=False)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/commands.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/commands.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/commands.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/commands.py 2019-06-13 23:17:46.000000000 +0200 @@ -9,18 +9,31 @@ from azure.cli.command_modules.cosmosdb._client_factory import cf_db_accounts +from azure.cli.command_modules.cosmosdb._format import ( + database_output, + list_database_output, + collection_output, + list_collection_output, + list_connection_strings_output +) + def load_command_table(self, _): cosmosdb_sdk = CliCommandType( - operations_tmpl='azure.mgmt.cosmosdb.operations.database_accounts_operations#DatabaseAccountsOperations.{}', + operations_tmpl='azure.mgmt.cosmosdb.operations#DatabaseAccountsOperations.{}', client_factory=cf_db_accounts) + cosmosdb_custom_sdk = CliCommandType( + operations_tmpl='azure.cli.command_modules.cosmosdb.custom#{}', + client_factory=cf_db_accounts + ) + with self.command_group('cosmosdb', cosmosdb_sdk, client_factory=cf_db_accounts) as g: g.show_command('show', 'get') - g.command('list-keys', 'list_keys') + g.command('list-keys', 'list_keys', deprecate_info=g.deprecate(redirect='cosmosdb keys list', hide=True)) g.command('list-read-only-keys', 'list_read_only_keys') - g.command('list-connection-strings', 'list_connection_strings') + g.command('list-connection-strings', 'list_connection_strings', table_transformer=list_connection_strings_output) g.command('regenerate-key', 'regenerate_key') g.command('check-name-exists', 'check_name_exists') g.command('delete', 'delete') @@ -29,19 +42,29 @@ g.custom_command('update', 'cli_cosmosdb_update') g.custom_command('list', 'cli_cosmosdb_list') + # virtual network rules + with self.command_group('cosmosdb network-rule', cosmosdb_custom_sdk, client_factory=cf_db_accounts) as g: + g.custom_command('list', 'cli_cosmosdb_network_rule_list') + g.custom_command('add', 'cli_cosmosdb_network_rule_add') + g.custom_command('remove', 'cli_cosmosdb_network_rule_remove') + + # key operations + with self.command_group('cosmosdb keys', cosmosdb_sdk) as g: + g.command('list', 'list_keys') + # # database operations 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('show', 'cli_cosmosdb_database_show', table_transformer=database_output) + g.cosmosdb_custom('list', 'cli_cosmosdb_database_list', table_transformer=list_database_output) g.cosmosdb_custom('exists', 'cli_cosmosdb_database_exists') - g.cosmosdb_custom('create', 'cli_cosmosdb_database_create') + g.cosmosdb_custom('create', 'cli_cosmosdb_database_create', table_transformer=database_output) g.cosmosdb_custom('delete', 'cli_cosmosdb_database_delete') # collection operations 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('show', 'cli_cosmosdb_collection_show', table_transformer=collection_output) + g.cosmosdb_custom('list', 'cli_cosmosdb_collection_list', table_transformer=list_collection_output) g.cosmosdb_custom('exists', 'cli_cosmosdb_collection_exists') - g.cosmosdb_custom('create', 'cli_cosmosdb_collection_create') + g.cosmosdb_custom('create', 'cli_cosmosdb_collection_create', table_transformer=collection_output) 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.2.7/azure/cli/command_modules/cosmosdb/custom.py new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/custom.py --- old/azure-cli-cosmosdb-0.2.7/azure/cli/command_modules/cosmosdb/custom.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure/cli/command_modules/cosmosdb/custom.py 2019-06-13 23:17:46.000000000 +0200 @@ -10,7 +10,8 @@ ConsistencyPolicy, DatabaseAccountCreateUpdateParameters, Location, - DatabaseAccountKind + DatabaseAccountKind, + VirtualNetworkRule ) logger = get_logger(__name__) @@ -67,7 +68,8 @@ resource_group_location = rg.location # pylint: disable=no-member if not locations: - locations.append(Location(location_name=resource_group_location, failover_priority=0)) + locations = [] + locations.append(Location(location_name=resource_group_location, failover_priority=0, is_zone_redundant=False)) params = DatabaseAccountCreateUpdateParameters( location=resource_group_location, @@ -167,9 +169,12 @@ consistency_policy = existing.consistency_policy if not locations: + locations = [] for loc in existing.read_locations: locations.append( - Location(location_name=loc.location_name, failover_priority=loc.failover_priority)) + Location(location_name=loc.location_name, + failover_priority=loc.failover_priority, + is_zone_redundant=loc.is_zone_redundant)) if ip_range_filter is None: ip_range_filter = existing.ip_range_filter @@ -188,10 +193,8 @@ if enable_multiple_write_locations is None: enable_multiple_write_locations = existing.enable_multiple_write_locations - elif enable_multiple_write_locations != existing.enable_multiple_write_locations and \ - enable_multiple_write_locations: - raise CLIError("Cannot convert account from single master to multi master") - elif enable_multiple_write_locations != existing.enable_multiple_write_locations: + elif enable_multiple_write_locations != existing.enable_multiple_write_locations \ + and not enable_multiple_write_locations: logger.warning("Updating the account from multi master to single master will take 24 hours to complete.") params = DatabaseAccountCreateUpdateParameters( @@ -221,6 +224,127 @@ return client.list() +def cli_cosmosdb_network_rule_list(client, resource_group_name, account_name): + """ Lists the virtual network accounts associated with a Cosmos DB account """ + cosmos_db_account = client.get(resource_group_name, account_name) + return cosmos_db_account.virtual_network_rules + + +def _get_virtual_network_id(cmd, resource_group_name, subnet, virtual_network): + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if not is_valid_resource_id(subnet): + if virtual_network is None: + raise CLIError("usage error: --subnet ID | --subnet NAME --vnet-name NAME") + subnet = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=resource_group_name, + namespace='Microsoft.Network', type='virtualNetworks', + name=virtual_network, child_type_1='subnets', child_name_1=subnet + ) + return subnet + + +def cli_cosmosdb_network_rule_add(cmd, + client, + resource_group_name, + account_name, + subnet, + virtual_network=None, + ignore_missing_vnet_service_endpoint=False): + """ Adds a virtual network rule to an existing Cosmos DB database account """ + subnet = _get_virtual_network_id(cmd, resource_group_name, subnet, virtual_network) + existing = client.get(resource_group_name, account_name) + + virtual_network_rules = [] + rule_already_exists = False + for rule in existing.virtual_network_rules: + virtual_network_rules.append( + VirtualNetworkRule(id=rule.id, + ignore_missing_vnet_service_endpoint=rule.ignore_missing_vnet_service_endpoint)) + if rule.id == subnet: + rule_already_exists = True + logger.warning("The rule exists and will be overwritten") + + if not rule_already_exists: + virtual_network_rules.append( + VirtualNetworkRule(id=subnet, + ignore_missing_vnet_service_endpoint=ignore_missing_vnet_service_endpoint)) + + locations = [] + for loc in existing.read_locations: + locations.append( + Location(location_name=loc.location_name, + failover_priority=loc.failover_priority, + is_zone_redundant=loc.is_zone_redundant)) + + params = DatabaseAccountCreateUpdateParameters( + location=existing.location, + locations=locations, + tags=existing.tags, + kind=existing.kind, + consistency_policy=existing.consistency_policy, + ip_range_filter=existing.ip_range_filter, + enable_automatic_failover=existing.enable_automatic_failover, + capabilities=existing.capabilities, + is_virtual_network_filter_enabled=True, + virtual_network_rules=virtual_network_rules, + enable_multiple_write_locations=existing.enable_multiple_write_locations) + + async_docdb_create = client.create_or_update(resource_group_name, account_name, params) + docdb_account = async_docdb_create.result() + docdb_account = client.get(resource_group_name, account_name) # Workaround + return docdb_account + + +def cli_cosmosdb_network_rule_remove(cmd, + client, + resource_group_name, + account_name, + subnet, + virtual_network=None): + """ Adds a virtual network rule to an existing Cosmos DB database account """ + subnet = _get_virtual_network_id(cmd, resource_group_name, subnet, virtual_network) + existing = client.get(resource_group_name, account_name) + + virtual_network_rules = [] + rule_removed = False + for rule in existing.virtual_network_rules: + if rule.id != subnet: + virtual_network_rules.append( + VirtualNetworkRule(id=rule.id, + ignore_missing_vnet_service_endpoint=rule.ignore_missing_vnet_service_endpoint)) + else: + rule_removed = True + if not rule_removed: + raise CLIError("This rule does not exist for the Cosmos DB account") + + locations = [] + for loc in existing.read_locations: + locations.append( + Location(location_name=loc.location_name, + failover_priority=loc.failover_priority, + is_zone_redundant=loc.is_zone_redundant)) + + params = DatabaseAccountCreateUpdateParameters( + location=existing.location, + locations=locations, + tags=existing.tags, + kind=existing.kind, + consistency_policy=existing.consistency_policy, + ip_range_filter=existing.ip_range_filter, + enable_automatic_failover=existing.enable_automatic_failover, + capabilities=existing.capabilities, + is_virtual_network_filter_enabled=True, + virtual_network_rules=virtual_network_rules, + enable_multiple_write_locations=existing.enable_multiple_write_locations) + + async_docdb_create = client.create_or_update(resource_group_name, account_name, params) + docdb_account = async_docdb_create.result() + docdb_account = client.get(resource_group_name, account_name) # Workaround + return docdb_account + + ###################### # data plane APIs ###################### @@ -270,7 +394,7 @@ def cli_cosmosdb_collection_exists(client, database_id, collection_id): """Returns a boolean indicating whether the collection exists """ - return len(list(client.QueryCollections( + return len(list(client.QueryContainers( _get_database_link(database_id), {'query': 'SELECT * FROM root r WHERE r.id=@id', 'parameters': [{'name': '@id', 'value': collection_id}]}))) > 0 @@ -278,19 +402,19 @@ def cli_cosmosdb_collection_show(client, database_id, collection_id): """Shows an Azure Cosmos DB collection and its offer """ - collection = client.ReadCollection(_get_collection_link(database_id, collection_id)) + collection = client.ReadContainer(_get_collection_link(database_id, collection_id)) offer = _find_offer(client, collection['_self']) return {'collection': collection, 'offer': offer} def cli_cosmosdb_collection_list(client, database_id): """Lists all Azure Cosmos DB collections """ - return list(client.ReadCollections(_get_database_link(database_id))) + return list(client.ReadContainers(_get_database_link(database_id))) def cli_cosmosdb_collection_delete(client, database_id, collection_id): """Deletes an Azure Cosmos DB collection """ - client.DeleteCollection(_get_collection_link(database_id, collection_id)) + client.DeleteContainer(_get_collection_link(database_id, collection_id)) def _populate_collection_definition(collection, @@ -333,8 +457,8 @@ default_ttl, indexing_policy) - created_collection = client.CreateCollection(_get_database_link(database_id), collection, - options) + created_collection = client.CreateContainer(_get_database_link(database_id), collection, + options) offer = _find_offer(client, created_collection['_self']) return {'collection': created_collection, 'offer': offer} @@ -356,7 +480,7 @@ indexing_policy=None): """Updates an Azure Cosmos DB collection """ logger.debug('reading collection') - collection = client.ReadCollection(_get_collection_link(database_id, collection_id)) + collection = client.ReadContainer(_get_collection_link(database_id, collection_id)) result = {} if (_populate_collection_definition(collection, @@ -364,7 +488,7 @@ default_ttl, indexing_policy)): logger.debug('replacing collection') - result['collection'] = client.ReplaceCollection( + result['collection'] = client.ReplaceContainer( _get_collection_link(database_id, collection_id), collection) if throughput: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure_cli_cosmosdb.egg-info/PKG-INFO new/azure-cli-cosmosdb-0.2.11/azure_cli_cosmosdb.egg-info/PKG-INFO --- old/azure-cli-cosmosdb-0.2.7/azure_cli_cosmosdb.egg-info/PKG-INFO 2019-01-11 05:42:28.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure_cli_cosmosdb.egg-info/PKG-INFO 2019-06-13 23:18:19.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: azure-cli-cosmosdb -Version: 0.2.7 +Version: 0.2.11 Summary: Microsoft Azure Command-Line Tools Cosmos DB Command Module Home-page: https://github.com/Azure/azure-cli Author: Microsoft Corporation @@ -20,6 +20,23 @@ Release History =============== + 0.2.11 + ++++++ + * Added command `keys list` and deprecated `list-keys`. + * `cosmsodb create/update`: Added new format for --location to allow setting "isZoneRedundant" property. Deprecated old format. + + 0.2.10 + ++++++ + * Minor fixes. + + 0.2.9 + +++++ + * Introducing support for --enable-multiple-write-locations on account update + + 0.2.8 + +++++ + * Introduce `network-rule` subgroup with commands `add`, `remove`, and `list` for managing VNET rules of a Cosmos DB account + 0.2.7 +++++ * Added support for creating database with shared throughput diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/azure_cli_cosmosdb.egg-info/SOURCES.txt new/azure-cli-cosmosdb-0.2.11/azure_cli_cosmosdb.egg-info/SOURCES.txt --- old/azure-cli-cosmosdb-0.2.7/azure_cli_cosmosdb.egg-info/SOURCES.txt 2019-01-11 05:42:28.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure_cli_cosmosdb.egg-info/SOURCES.txt 2019-06-13 23:18:19.000000000 +0200 @@ -10,9 +10,11 @@ azure/cli/command_modules/cosmosdb/_client_factory.py azure/cli/command_modules/cosmosdb/_command_type.py azure/cli/command_modules/cosmosdb/_exception_handler.py +azure/cli/command_modules/cosmosdb/_format.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/actions.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.2.7/azure_cli_cosmosdb.egg-info/requires.txt new/azure-cli-cosmosdb-0.2.11/azure_cli_cosmosdb.egg-info/requires.txt --- old/azure-cli-cosmosdb-0.2.7/azure_cli_cosmosdb.egg-info/requires.txt 2019-01-11 05:42:28.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/azure_cli_cosmosdb.egg-info/requires.txt 2019-06-13 23:18:19.000000000 +0200 @@ -1,3 +1,3 @@ -azure-mgmt-cosmosdb==0.5.2 +azure-mgmt-cosmosdb==0.6.1 azure-cli-core -pydocumentdb>=2.0.1 +azure-cosmos>=3.0.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-cosmosdb-0.2.7/setup.py new/azure-cli-cosmosdb-0.2.11/setup.py --- old/azure-cli-cosmosdb-0.2.7/setup.py 2019-01-11 05:42:07.000000000 +0100 +++ new/azure-cli-cosmosdb-0.2.11/setup.py 2019-06-13 23:17:46.000000000 +0200 @@ -16,7 +16,7 @@ cmdclass = {} -VERSION = "0.2.7" +VERSION = "0.2.11" # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers CLASSIFIERS = [ @@ -34,9 +34,9 @@ DEPENDENCIES = [ - 'azure-mgmt-cosmosdb==0.5.2', + 'azure-mgmt-cosmosdb==0.6.1', 'azure-cli-core', - 'pydocumentdb>=2.0.1' + 'azure-cosmos>=3.0.2' ] with open('README.rst', 'r', encoding='utf-8') as f:
