From 59c571ba28e97d79e039b7372cb82915c93987aa Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Fri, 20 Jan 2017 11:40:12 -0800 Subject: [PATCH 01/15] Initial documentdb commandlet --- .../azure-cli-documentdb/HISTORY.rst | 5 ++ .../azure-cli-documentdb/MANIFEST.in | 1 + .../azure-cli-documentdb/README.rst | 7 ++ .../azure-cli-documentdb/azure/__init__.py | 7 ++ .../azure/cli/__init__.py | 7 ++ .../azure/cli/command_modules/__init__.py | 7 ++ .../command_modules/documentdb/__init__.py | 12 +++ .../documentdb/_client_factory.py | 14 ++++ .../cli/command_modules/documentdb/_help.py | 34 +++++++++ .../cli/command_modules/documentdb/_params.py | 64 ++++++++++++++++ .../command_modules/documentdb/commands.py | 27 +++++++ .../cli/command_modules/documentdb/custom.py | 74 +++++++++++++++++++ .../documentdb/tests/__init__.py | 4 + .../tests/test_documentdb_params.py | 46 ++++++++++++ .../azure-cli-documentdb/setup.cfg | 2 + .../azure-cli-documentdb/setup.py | 58 +++++++++++++++ 16 files changed, 369 insertions(+) create mode 100644 src/command_modules/azure-cli-documentdb/HISTORY.rst create mode 100644 src/command_modules/azure-cli-documentdb/MANIFEST.in create mode 100644 src/command_modules/azure-cli-documentdb/README.rst create mode 100644 src/command_modules/azure-cli-documentdb/azure/__init__.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/__init__.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/__init__.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/__init__.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/__init__.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/test_documentdb_params.py create mode 100644 src/command_modules/azure-cli-documentdb/setup.cfg create mode 100644 src/command_modules/azure-cli-documentdb/setup.py diff --git a/src/command_modules/azure-cli-documentdb/HISTORY.rst b/src/command_modules/azure-cli-documentdb/HISTORY.rst new file mode 100644 index 00000000000..df5defb7fe8 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/HISTORY.rst @@ -0,0 +1,5 @@ +.. :changelog: + +Release History +=============== + diff --git a/src/command_modules/azure-cli-documentdb/MANIFEST.in b/src/command_modules/azure-cli-documentdb/MANIFEST.in new file mode 100644 index 00000000000..bb37a2723da --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/MANIFEST.in @@ -0,0 +1 @@ +include *.rst diff --git a/src/command_modules/azure-cli-documentdb/README.rst b/src/command_modules/azure-cli-documentdb/README.rst new file mode 100644 index 00000000000..823ecc4bd3d --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/README.rst @@ -0,0 +1,7 @@ +Microsoft Azure CLI 'documentdb' Command Module +================================== + +This package is for the 'documentdb' module. +i.e. 'az documentdb' + + diff --git a/src/command_modules/azure-cli-documentdb/azure/__init__.py b/src/command_modules/azure-cli-documentdb/azure/__init__.py new file mode 100644 index 00000000000..a9dfa5391b9 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/__init__.py @@ -0,0 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# 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-documentdb/azure/cli/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/__init__.py new file mode 100644 index 00000000000..a9dfa5391b9 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/__init__.py @@ -0,0 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# 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-documentdb/azure/cli/command_modules/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/__init__.py new file mode 100644 index 00000000000..a9dfa5391b9 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/__init__.py @@ -0,0 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# 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-documentdb/azure/cli/command_modules/documentdb/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/__init__.py new file mode 100644 index 00000000000..0192377ec9b --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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.documentdb._help # pylint: disable=unused-import + +def load_params(_): + import azure.cli.command_modules.documentdb._params #pylint: disable=redefined-outer-name + +def load_commands(): + import azure.cli.command_modules.documentdb.commands #pylint: disable=redefined-outer-name diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py new file mode 100644 index 00000000000..8db0ecbcbb3 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +def cf_documentdb(_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azure.mgmt.documentdb import DocumentDB + return get_mgmt_service_client(DocumentDB).documentdb + +def cf_patch_schedules(_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azure.mgmt.documentdb import documentdbManagementClient + return get_mgmt_service_client(documentdbManagementClient).patch_schedules diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py new file mode 100644 index 00000000000..d483009539d --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py @@ -0,0 +1,34 @@ +# -------------------------------------------------------------------------------------------- +# 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 #pylint: disable=unused-import + +#pylint: disable=line-too-long + +# helps['documentdb'] = """ +# type: group +# short-summary: Access to a secure, dedicated cache for your Azure applications +# long-summary: If you don't have the documentdb component installed, add it with `az component update --add documentdb` +# """ + +# helps['documentdb export'] = """ +# type: command +# short-summary: Export data stored in a documentdb cache. +# """ + +# helps['documentdb import-method'] = """ +# type: command +# short-summary: Import data into a documentdb cache. +# """ + +# helps['documentdb update-settings'] = """ +# type: command +# short-summary: Update the settings of a documentdb cache. +# """ + +# helps['documentdb patch-schedule'] = """ +# type: group +# short-summary: Commands to manage documentdb patch schedules +# """ \ No newline at end of file diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py new file mode 100644 index 00000000000..927a31658a2 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -0,0 +1,64 @@ +# -------------------------------------------------------------------------------------------- +# 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.parameters import ( + get_resource_name_completion_list, + enum_choice_list, + name_type) +from azure.cli.core.commands import register_cli_argument +import azure.cli.core.commands.arm # pylint: disable=unused-import +# from azure.mgmt.documentdb.models.documentdb_management_client_enums import ( +# RebootType, +# documentdbKeyType, +# SkuFamily, +# SkuName) + +# from azure.mgmt.documentdb.models import ( +# ScheduleEntry, +# ) + +# class JsonString(dict): + +# def __init__(self, value): +# super(JsonString, self).__init__() +# import json +# if value[0] in ("'", '"') and value[-1] == value[0]: +# # Remove leading and trailing quotes for dos/cmd.exe users +# value = value[1:-1] +# dictval = json.loads(value) +# self.update(dictval) + +# class ScheduleEntryList(list): +# def __init__(self, value): +# super(ScheduleEntryList, self).__init__() +# import json +# if value[0] in ("'", '"') and value[-1] == value[0]: +# # Remove leading and trailing quotes for dos/cmd.exe users +# value = value[1:-1] +# dictval = json.loads(value) +# self.extend([ScheduleEntry( +# row['dayOfWeek'], +# int(row['startHourUtc']), +# row.get('maintenanceWindow', None)) +# for row in dictval]) + +# register_cli_argument('documentdb', 'name', arg_type=name_type, help='Name of the documentdb cache.', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part='name') +# register_cli_argument('documentdb', 'documentdb_configuration', type=JsonString) +# register_cli_argument('documentdb', 'reboot_type', **enum_choice_list(RebootType)) +# register_cli_argument('documentdb', 'key_type', **enum_choice_list(documentdbKeyType)) +# register_cli_argument('documentdb', 'shard_id', type=int) +# register_cli_argument('documentdb import-method', 'files', nargs='+') + +# register_cli_argument('documentdb patch-schedule set', 'schedule_entries', type=ScheduleEntryList) + +# register_cli_argument('documentdb create', 'name', arg_type=name_type, completer=None) +# register_cli_argument('documentdb create', 'sku_name', **enum_choice_list(SkuName)) +# register_cli_argument('documentdb create', 'sku_family', **enum_choice_list(SkuFamily)) +# register_cli_argument('documentdb create', 'sku_capacity', choices=[str(n) for n in range(0, 7)]) +# register_cli_argument('documentdb create', 'enable_non_ssl_port', action='store_true') +# register_cli_argument('documentdb create', 'tenant_settings', type=JsonString) +# register_cli_argument('documentdb create', 'shard_count', type=int) +# register_cli_argument('documentdb create', 'subnet_id') # TODO: Create generic id completer similar to name diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py new file mode 100644 index 00000000000..8974b92bcdd --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.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 + +from azure.cli.core.commands import cli_command +import azure.cli.command_modules.documentdb +# from azure.cli.command_modules.documentdb._client_factory import (cf_documentdb, cf_patch_schedules) + +cli_command(__name__, 'documentdb create', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_create', cf_documentdb) +# cli_command(__name__, 'documentdb delete', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.delete', cf_documentdb) +# cli_command(__name__, 'documentdb export', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_export', cf_documentdb) +# cli_command(__name__, 'documentdb force-reboot', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.force_reboot', cf_documentdb) +# cli_command(__name__, 'documentdb import-method', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_import_method', cf_documentdb) +# cli_command(__name__, 'documentdb list', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.list_by_resource_group', cf_documentdb) +# cli_command(__name__, 'documentdb list-all', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.list', cf_documentdb) +# cli_command(__name__, 'documentdb list-keys', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.list_keys', cf_documentdb) +# cli_command(__name__, 'documentdb regenerate-keys', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.regenerate_key', cf_documentdb) +cli_command(__name__, 'documentdb show', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.get', cf_documentdb) +# cli_command(__name__, 'documentdb update-settings', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_update_settings', cf_documentdb) + +# cli_command(__name__, 'documentdb patch-schedule set', 'azure.mgmt.documentdb.operations.patch_schedules_operations#PatchSchedulesOperations.create_or_update', cf_patch_schedules) +# cli_command(__name__, 'documentdb patch-schedule delete', 'azure.mgmt.documentdb.operations.patch_schedules_operations#PatchSchedulesOperations.delete', cf_patch_schedules) +# cli_command(__name__, 'documentdb patch-schedule show', 'azure.mgmt.documentdb.operations.patch_schedules_operations#PatchSchedulesOperations.get', cf_patch_schedules) + diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py new file mode 100644 index 00000000000..8c9f6da2a70 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -0,0 +1,74 @@ +# -------------------------------------------------------------------------------------------- +# 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.documentdb.models import ( + ImportRDBParameters, + ExportRDBParameters, + documentdbCreateOrUpdateParameters, + Sku, +) + +def cli_documentdb_export(client, resource_group_name, name, prefix, container, file_format=None): + # pylint:disable=too-many-arguments + parameters = ExportRDBParameters(prefix, container, file_format) + return client.export(resource_group_name, name, parameters) + +def cli_documentdb_import_method(client, resource_group_name, name, file_format, files): + parameters = ImportRDBParameters(files, file_format) + return client.import_method(resource_group_name, name, files, parameters) + +def cli_documentdb_update_settings(client, resource_group_name, name, documentdb_configuration): + existing = client.get(resource_group_name, name) + existing.documentdb_configuration.update(documentdb_configuration) + + # Due to swagger/mgmt SDK quirkiness, we have to manually copy over + # the resource retrieved to a create_or_update_parameters object + update_params = documentdbCreateOrUpdateParameters( + existing.location, + existing.sku, + existing.tags, + existing.documentdb_version, + existing.documentdb_configuration, + existing.enable_non_ssl_port, + existing.tenant_settings, + existing.shard_count, + existing.subnet_id, + existing.static_ip, + ) + return client.create_or_update(resource_group_name, name, parameters=update_params) + +def cli_documentdb_create(client, resource_group_name, name, location, sku_name, # pylint:disable=too-many-arguments + sku_family, sku_capacity, tags=None, documentdb_configuration=None, + enable_non_ssl_port=None, tenant_settings=None, shard_count=None, + subnet_id=None, static_ip=None): + # pylint:disable=line-too-long + """Create new documentdb Cache instance + :param resource_group_name: Name of resource group + :param name: Name of documentdb cache + :param location: Location + :param sku_name: What type of documentdb cache to deploy. Valid values: (Basic, Standard, Premium). + :param sku_family: Which family to use. Valid values: (C, P). + :param sku_capacity: What size of documentdb cache to deploy. Valid values for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4) + :param documentdb_configuration: All documentdb Settings. Few possible keys rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set-max-intset-entries, zset-max-ziplist-entries, zset-max-ziplist-value etc. + :param enable_non_ssl_port: If the value is true, then the non-ssl documentdb server port (6379) will be enabled. + :param tenant_settings: Json dictionary with tenant settings + :param shard_count: The number of shards to be created on a Premium Cluster Cache. + :param subnet_id: The full resource ID of a subnet in a virtual network to deploy the documentdb cache in. Example format /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 + :param static_ip: Required when deploying a documentdb cache inside an existing Azure Virtual Network. + """ + params = documentdbCreateOrUpdateParameters( + location, + Sku(sku_name, sku_family, sku_capacity), + tags, + None, # Version is deprecated and ignored + documentdb_configuration, + enable_non_ssl_port, + tenant_settings, + shard_count, + subnet_id, + static_ip) + + return client.create_or_update(resource_group_name, name, params) + diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/__init__.py new file mode 100644 index 00000000000..34913fb394d --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/__init__.py @@ -0,0 +1,4 @@ +# -------------------------------------------------------------------------------------------- +# 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-documentdb/azure/cli/command_modules/documentdb/tests/test_documentdb_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/test_documentdb_params.py new file mode 100644 index 00000000000..335cb21bde7 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/test_documentdb_params.py @@ -0,0 +1,46 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import unittest + +from azure.cli.core.application import APPLICATION, Configuration + +def mock_echo_args(command_name, parameters): + try: + argv = ' '.join((command_name, parameters)).split() + APPLICATION.initialize(Configuration(argv)) + command_table = APPLICATION.configuration.get_command_table() + prefunc = command_table[command_name].handler + command_table[command_name].handler = lambda args: args + parsed_namespace = APPLICATION.execute(argv) + return parsed_namespace + finally: + command_table[command_name].handler = prefunc + +class Test_documentdbCache(unittest.TestCase): + + @classmethod + def setUpClass(cls): + pass + + def test_parse_documentdb_create(self): + + args = mock_echo_args('documentdb create', + '--tenant-settings {\"hello\":1} -g wombat -n asldkj --sku-family c -l westus --sku-capacity 1 --sku-name basic') # pylint: disable=line-too-long + subset = set(dict( + sku_family='C', + sku_capacity='1', + sku_name='Basic', + name='asldkj' + ).items()) + + superset = set([(k, v) for k, v in args.result.items() if not isinstance(v, dict)]) + + self.assertTrue( + subset.issubset(superset) + ) + + tenant_settings = dict(hello=1) + self.assertDictEqual(tenant_settings, args.result['tenant_settings']) diff --git a/src/command_modules/azure-cli-documentdb/setup.cfg b/src/command_modules/azure-cli-documentdb/setup.cfg new file mode 100644 index 00000000000..3c6e79cf31d --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/command_modules/azure-cli-documentdb/setup.py b/src/command_modules/azure-cli-documentdb/setup.py new file mode 100644 index 00000000000..a7b164b5c32 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/setup.py @@ -0,0 +1,58 @@ +#!/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 + +VERSION = '0.1.1b1+dev' + +# 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', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [ + 'azure-mgmt-documentdb==1.0.0', + 'azure-cli-core', +] + +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-documentdb', + version=VERSION, + description='Microsoft Azure Command-Line Tools documentdb Command Module', + long_description=README + '\n\n' + HISTORY, + 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.documentdb', + ], + install_requires=DEPENDENCIES, +) From 8343d2bde735922cad97896ea7c3a7521c33fa69 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Fri, 20 Jan 2017 16:58:26 -0800 Subject: [PATCH 02/15] most commands completed --- .../documentdb/_client_factory.py | 9 +- .../cli/command_modules/documentdb/_help.py | 10 +- .../cli/command_modules/documentdb/_params.py | 63 +- .../command_modules/documentdb/commands.py | 32 +- .../cli/command_modules/documentdb/custom.py | 124 +-- .../documentdb/sdk/__init__.py | 18 + .../documentdb/sdk/document_db.py | 118 +++ .../documentdb/sdk/models/__init__.py | 48 + .../sdk/models/consistency_policy.py | 50 + .../documentdb/sdk/models/database_account.py | 110 +++ ...tabase_account_create_update_parameters.py | 76 ++ .../database_account_list_keys_result.py | 53 ++ ...base_account_list_read_only_keys_result.py | 41 + .../sdk/models/database_account_paged.py | 27 + .../database_account_patch_parameters.py | 31 + ...abase_account_regenerate_key_parameters.py | 33 + .../sdk/models/document_db_enums.py | 40 + .../sdk/models/failover_policies.py | 28 + .../documentdb/sdk/models/failover_policy.py | 48 + .../documentdb/sdk/models/location.py | 58 ++ .../documentdb/sdk/models/resource.py | 54 ++ .../documentdb/sdk/operations/__init__.py | 16 + .../database_accounts_operations.py | 853 ++++++++++++++++++ .../command_modules/documentdb/sdk/version.py | 13 + .../azure-cli-documentdb/setup.py | 3 +- 25 files changed, 1819 insertions(+), 137 deletions(-) create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/__init__.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/__init__.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/document_db_enums.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py create mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py index 8db0ecbcbb3..72def8e1823 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py @@ -5,10 +5,5 @@ def cf_documentdb(_): from azure.cli.core.commands.client_factory import get_mgmt_service_client - from azure.mgmt.documentdb import DocumentDB - return get_mgmt_service_client(DocumentDB).documentdb - -def cf_patch_schedules(_): - from azure.cli.core.commands.client_factory import get_mgmt_service_client - from azure.mgmt.documentdb import documentdbManagementClient - return get_mgmt_service_client(documentdbManagementClient).patch_schedules + from azure.cli.command_modules.documentdb.sdk import DocumentDB + return get_mgmt_service_client(DocumentDB) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py index d483009539d..ef3a8ed294a 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py @@ -7,11 +7,11 @@ #pylint: disable=line-too-long -# helps['documentdb'] = """ -# type: group -# short-summary: Access to a secure, dedicated cache for your Azure applications -# long-summary: If you don't have the documentdb component installed, add it with `az component update --add documentdb` -# """ +helps['documentdb'] = """ + type: group + short-summary: Managed NoSQL Database + long-summary: +""" # helps['documentdb export'] = """ # type: command diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index 927a31658a2..eaca896a858 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -10,55 +10,24 @@ name_type) from azure.cli.core.commands import register_cli_argument import azure.cli.core.commands.arm # pylint: disable=unused-import -# from azure.mgmt.documentdb.models.documentdb_management_client_enums import ( -# RebootType, -# documentdbKeyType, -# SkuFamily, -# SkuName) +from azure.cli.core.commands import CliArgumentType +from azure.cli.command_modules.documentdb.sdk.models.document_db_enums import KeyKind +from azure.cli.command_modules.documentdb.sdk.models.failover_policy import FailoverPolicy -# from azure.mgmt.documentdb.models import ( -# ScheduleEntry, -# ) -# class JsonString(dict): +def validate_failover_policies(ns): + ''' Extracts multiple space-separated failoverPolcies in region=failoverPriority format ''' + tags_dict = [] + for item in ns.failover_policies: + print(item) + comps = item.split('=', 1) + tags_dict.append(FailoverPolicy(comps[0], int(comps[1]))) + ns.failover_policies = tags_dict + return ns -# def __init__(self, value): -# super(JsonString, self).__init__() -# import json -# if value[0] in ("'", '"') and value[-1] == value[0]: -# # Remove leading and trailing quotes for dos/cmd.exe users -# value = value[1:-1] -# dictval = json.loads(value) -# self.update(dictval) -# class ScheduleEntryList(list): -# def __init__(self, value): -# super(ScheduleEntryList, self).__init__() -# import json -# if value[0] in ("'", '"') and value[-1] == value[0]: -# # Remove leading and trailing quotes for dos/cmd.exe users -# value = value[1:-1] -# dictval = json.loads(value) -# self.extend([ScheduleEntry( -# row['dayOfWeek'], -# int(row['startHourUtc']), -# row.get('maintenanceWindow', None)) -# for row in dictval]) +register_cli_argument('documentdb', 'account_name', arg_type=name_type, help='name of the DocumentDB Database Account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part="name") -# register_cli_argument('documentdb', 'name', arg_type=name_type, help='Name of the documentdb cache.', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part='name') -# register_cli_argument('documentdb', 'documentdb_configuration', type=JsonString) -# register_cli_argument('documentdb', 'reboot_type', **enum_choice_list(RebootType)) -# register_cli_argument('documentdb', 'key_type', **enum_choice_list(documentdbKeyType)) -# register_cli_argument('documentdb', 'shard_id', type=int) -# register_cli_argument('documentdb import-method', 'files', nargs='+') - -# register_cli_argument('documentdb patch-schedule set', 'schedule_entries', type=ScheduleEntryList) - -# register_cli_argument('documentdb create', 'name', arg_type=name_type, completer=None) -# register_cli_argument('documentdb create', 'sku_name', **enum_choice_list(SkuName)) -# register_cli_argument('documentdb create', 'sku_family', **enum_choice_list(SkuFamily)) -# register_cli_argument('documentdb create', 'sku_capacity', choices=[str(n) for n in range(0, 7)]) -# register_cli_argument('documentdb create', 'enable_non_ssl_port', action='store_true') -# register_cli_argument('documentdb create', 'tenant_settings', type=JsonString) -# register_cli_argument('documentdb create', 'shard_count', type=int) -# register_cli_argument('documentdb create', 'subnet_id') # TODO: Create generic id completer similar to name +register_cli_argument('documentdb regenerate-key', 'key_kind', **enum_choice_list(KeyKind)) +register_cli_argument('documentdb failover-priority-change', 'failover_policies', validator=validate_failover_policies, help="space separated failover policies in 'region=failoverPriority' format. E.g \"East US\"=0", nargs='+') +# register_cli_argument('documentdb create', ) \ No newline at end of file diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py index 8974b92bcdd..cfed6fd2457 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py @@ -7,21 +7,25 @@ from azure.cli.core.commands import cli_command import azure.cli.command_modules.documentdb -# from azure.cli.command_modules.documentdb._client_factory import (cf_documentdb, cf_patch_schedules) +from azure.cli.command_modules.documentdb._client_factory import (cf_documentdb) -cli_command(__name__, 'documentdb create', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_create', cf_documentdb) -# cli_command(__name__, 'documentdb delete', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.delete', cf_documentdb) +cli_command(__name__, 'documentdb show', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.get', cf_documentdb) +cli_command(__name__, 'documentdb list', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.list_by_resource_group', cf_documentdb) +cli_command(__name__, 'documentdb list-all', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.list', cf_documentdb) +cli_command(__name__, 'documentdb list-keys', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.list_keys', cf_documentdb) +cli_command(__name__, 'documentdb list-read-only-keys', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.list_read_only_keys', cf_documentdb) +cli_command(__name__, 'documentdb regenerate-key', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.regenerate_key', cf_documentdb) +cli_command(__name__, 'documentdb check-name-exists', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.check_name_exists', cf_documentdb) +cli_command(__name__, 'documentdb delete', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.delete', cf_documentdb) +cli_command(__name__, 'documentdb failover-priority-change', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.failover_priority_change', cf_documentdb) +cli_command(__name__, 'documentdb create', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.create_or_update', cf_documentdb) + +#createOrUpdate remember to add laurents fix +#failoverpriorityChange + +# cli_command(__name__, 'documentdb create', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_create', cf_documentdb) # cli_command(__name__, 'documentdb export', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_export', cf_documentdb) -# cli_command(__name__, 'documentdb force-reboot', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.force_reboot', cf_documentdb) +# cli_command(__name__, 'documentdb force-reboot', 'azure.cli.command_modules.documentdb.sdk.operations.documentdb_operations#documentdbOperations.force_reboot', cf_documentdb) # cli_command(__name__, 'documentdb import-method', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_import_method', cf_documentdb) -# cli_command(__name__, 'documentdb list', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.list_by_resource_group', cf_documentdb) -# cli_command(__name__, 'documentdb list-all', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.list', cf_documentdb) -# cli_command(__name__, 'documentdb list-keys', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.list_keys', cf_documentdb) -# cli_command(__name__, 'documentdb regenerate-keys', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.regenerate_key', cf_documentdb) -cli_command(__name__, 'documentdb show', 'azure.mgmt.documentdb.operations.documentdb_operations#documentdbOperations.get', cf_documentdb) +# cli_command(__name__, 'documentdb regenerate-keys', 'azure.cli.command_modules.documentdb.sdk.operations.documentdb_operations#documentdbOperations.regenerate_key', cf_documentdb) # cli_command(__name__, 'documentdb update-settings', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_update_settings', cf_documentdb) - -# cli_command(__name__, 'documentdb patch-schedule set', 'azure.mgmt.documentdb.operations.patch_schedules_operations#PatchSchedulesOperations.create_or_update', cf_patch_schedules) -# cli_command(__name__, 'documentdb patch-schedule delete', 'azure.mgmt.documentdb.operations.patch_schedules_operations#PatchSchedulesOperations.delete', cf_patch_schedules) -# cli_command(__name__, 'documentdb patch-schedule show', 'azure.mgmt.documentdb.operations.patch_schedules_operations#PatchSchedulesOperations.get', cf_patch_schedules) - diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index 8c9f6da2a70..3d061b942c9 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -3,72 +3,72 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.mgmt.documentdb.models import ( - ImportRDBParameters, - ExportRDBParameters, - documentdbCreateOrUpdateParameters, - Sku, -) +# from azure.cli.command_modules.documentdb.sdk.models import ( +# # ImportRDBParameters, +# # ExportRDBParameters, +# # documentdbCreateOrUpdateParameters, +# # Sku, +# ) -def cli_documentdb_export(client, resource_group_name, name, prefix, container, file_format=None): - # pylint:disable=too-many-arguments - parameters = ExportRDBParameters(prefix, container, file_format) - return client.export(resource_group_name, name, parameters) +# def cli_documentdb_export(client, resource_group_name, name, prefix, container, file_format=None): +# # pylint:disable=too-many-arguments +# parameters = ExportRDBParameters(prefix, container, file_format) +# return client.export(resource_group_name, name, parameters) -def cli_documentdb_import_method(client, resource_group_name, name, file_format, files): - parameters = ImportRDBParameters(files, file_format) - return client.import_method(resource_group_name, name, files, parameters) +# def cli_documentdb_import_method(client, resource_group_name, name, file_format, files): +# parameters = ImportRDBParameters(files, file_format) +# return client.import_method(resource_group_name, name, files, parameters) -def cli_documentdb_update_settings(client, resource_group_name, name, documentdb_configuration): - existing = client.get(resource_group_name, name) - existing.documentdb_configuration.update(documentdb_configuration) +# def cli_documentdb_update_settings(client, resource_group_name, name, documentdb_configuration): +# existing = client.get(resource_group_name, name) +# existing.documentdb_configuration.update(documentdb_configuration) - # Due to swagger/mgmt SDK quirkiness, we have to manually copy over - # the resource retrieved to a create_or_update_parameters object - update_params = documentdbCreateOrUpdateParameters( - existing.location, - existing.sku, - existing.tags, - existing.documentdb_version, - existing.documentdb_configuration, - existing.enable_non_ssl_port, - existing.tenant_settings, - existing.shard_count, - existing.subnet_id, - existing.static_ip, - ) - return client.create_or_update(resource_group_name, name, parameters=update_params) +# # Due to swagger/mgmt SDK quirkiness, we have to manually copy over +# # the resource retrieved to a create_or_update_parameters object +# update_params = documentdbCreateOrUpdateParameters( +# existing.location, +# existing.sku, +# existing.tags, +# existing.documentdb_version, +# existing.documentdb_configuration, +# existing.enable_non_ssl_port, +# existing.tenant_settings, +# existing.shard_count, +# existing.subnet_id, +# existing.static_ip, +# ) +# return client.create_or_update(resource_group_name, name, parameters=update_params) -def cli_documentdb_create(client, resource_group_name, name, location, sku_name, # pylint:disable=too-many-arguments - sku_family, sku_capacity, tags=None, documentdb_configuration=None, - enable_non_ssl_port=None, tenant_settings=None, shard_count=None, - subnet_id=None, static_ip=None): - # pylint:disable=line-too-long - """Create new documentdb Cache instance - :param resource_group_name: Name of resource group - :param name: Name of documentdb cache - :param location: Location - :param sku_name: What type of documentdb cache to deploy. Valid values: (Basic, Standard, Premium). - :param sku_family: Which family to use. Valid values: (C, P). - :param sku_capacity: What size of documentdb cache to deploy. Valid values for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4) - :param documentdb_configuration: All documentdb Settings. Few possible keys rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set-max-intset-entries, zset-max-ziplist-entries, zset-max-ziplist-value etc. - :param enable_non_ssl_port: If the value is true, then the non-ssl documentdb server port (6379) will be enabled. - :param tenant_settings: Json dictionary with tenant settings - :param shard_count: The number of shards to be created on a Premium Cluster Cache. - :param subnet_id: The full resource ID of a subnet in a virtual network to deploy the documentdb cache in. Example format /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 - :param static_ip: Required when deploying a documentdb cache inside an existing Azure Virtual Network. - """ - params = documentdbCreateOrUpdateParameters( - location, - Sku(sku_name, sku_family, sku_capacity), - tags, - None, # Version is deprecated and ignored - documentdb_configuration, - enable_non_ssl_port, - tenant_settings, - shard_count, - subnet_id, - static_ip) +# def cli_documentdb_create(client, resource_group_name, name, location, sku_name, # pylint:disable=too-many-arguments +# sku_family, sku_capacity, tags=None, documentdb_configuration=None, +# enable_non_ssl_port=None, tenant_settings=None, shard_count=None, +# subnet_id=None, static_ip=None): +# # pylint:disable=line-too-long +# """Create new documentdb Cache instance +# :param resource_group_name: Name of resource group +# :param name: Name of documentdb cache +# :param location: Location +# :param sku_name: What type of documentdb cache to deploy. Valid values: (Basic, Standard, Premium). +# :param sku_family: Which family to use. Valid values: (C, P). +# :param sku_capacity: What size of documentdb cache to deploy. Valid values for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4) +# :param documentdb_configuration: All documentdb Settings. Few possible keys rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set-max-intset-entries, zset-max-ziplist-entries, zset-max-ziplist-value etc. +# :param enable_non_ssl_port: If the value is true, then the non-ssl documentdb server port (6379) will be enabled. +# :param tenant_settings: Json dictionary with tenant settings +# :param shard_count: The number of shards to be created on a Premium Cluster Cache. +# :param subnet_id: The full resource ID of a subnet in a virtual network to deploy the documentdb cache in. Example format /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 +# :param static_ip: Required when deploying a documentdb cache inside an existing Azure Virtual Network. +# """ +# params = documentdbCreateOrUpdateParameters( +# location, +# Sku(sku_name, sku_family, sku_capacity), +# tags, +# None, # Version is deprecated and ignored +# documentdb_configuration, +# enable_non_ssl_port, +# tenant_settings, +# shard_count, +# subnet_id, +# static_ip) - return client.create_or_update(resource_group_name, name, params) +# return client.create_or_update(resource_group_name, name, params) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/__init__.py new file mode 100644 index 00000000000..3ec900145f1 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .document_db import DocumentDB +from .version import VERSION + +__all__ = ['DocumentDB'] + +__version__ = VERSION + diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py new file mode 100644 index 00000000000..804d09ed34e --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py @@ -0,0 +1,118 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import ServiceClient +from msrest import Serializer, Deserializer +from msrestazure import AzureConfiguration +from .version import VERSION +from .operations.database_accounts_operations import DatabaseAccountsOperations +from . import models + + +class DocumentDBConfiguration(AzureConfiguration): + """Configuration for DocumentDB + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param api_version: Version of the API to be used with the client request. + The current version is 2015-04-08. + :type api_version: str + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config + """ + + def __init__( + self, credentials, subscription_id, api_version='2015-04-08', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not isinstance(subscription_id, str): + raise TypeError("Parameter 'subscription_id' must be str.") + if api_version is not None and not isinstance(api_version, str): + raise TypeError("Optional parameter 'api_version' must be str.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") + if not base_url: + base_url = 'https://management.azure.com' + + super(DocumentDBConfiguration, self).__init__(base_url, filepath) + + self.add_user_agent('documentdb/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id + self.api_version = api_version + self.accept_language = accept_language + self.long_running_operation_retry_timeout = long_running_operation_retry_timeout + self.generate_client_request_id = generate_client_request_id + + +class DocumentDB(object): + """Azure DocumentDB Database Service Resource Provider REST API + + :ivar config: Configuration for client. + :vartype config: DocumentDBConfiguration + + :ivar database_accounts: DatabaseAccounts operations + :vartype database_accounts: .operations.DatabaseAccountsOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param api_version: Version of the API to be used with the client request. + The current version is 2015-04-08. + :type api_version: str + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config + """ + + def __init__( + self, credentials, subscription_id, api_version='2015-04-08', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): + + self.config = DocumentDBConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.database_accounts = DatabaseAccountsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/__init__.py new file mode 100644 index 00000000000..af5d37cf1c8 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/__init__.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .consistency_policy import ConsistencyPolicy +from .location import Location +from .failover_policy import FailoverPolicy +from .database_account import DatabaseAccount +from .failover_policies import FailoverPolicies +from .resource import Resource +from .database_account_create_update_parameters import DatabaseAccountCreateUpdateParameters +from .database_account_patch_parameters import DatabaseAccountPatchParameters +from .database_account_list_read_only_keys_result import DatabaseAccountListReadOnlyKeysResult +from .database_account_list_keys_result import DatabaseAccountListKeysResult +from .database_account_regenerate_key_parameters import DatabaseAccountRegenerateKeyParameters +from .database_account_paged import DatabaseAccountPaged +from .document_db_enums import ( + DatabaseAccountKind, + DatabaseAccountOfferType, + DefaultConsistencyLevel, + KeyKind, +) + +__all__ = [ + 'ConsistencyPolicy', + 'Location', + 'FailoverPolicy', + 'DatabaseAccount', + 'FailoverPolicies', + 'Resource', + 'DatabaseAccountCreateUpdateParameters', + 'DatabaseAccountPatchParameters', + 'DatabaseAccountListReadOnlyKeysResult', + 'DatabaseAccountListKeysResult', + 'DatabaseAccountRegenerateKeyParameters', + 'DatabaseAccountPaged', + 'DatabaseAccountKind', + 'DatabaseAccountOfferType', + 'DefaultConsistencyLevel', + 'KeyKind', +] diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py new file mode 100644 index 00000000000..fae7c28a59a --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ConsistencyPolicy(Model): + """The consistency policy for the DocumentDB database account. + + :param default_consistency_level: The default consistency level and + configuration settings of the DocumentDB account. Possible values include: + 'Eventual', 'Session', 'BoundedStaleness', 'Strong' + :type default_consistency_level: str or :class:`DefaultConsistencyLevel + ` + :param max_staleness_prefix: When used with the Bounded Staleness + consistency level, this value represents the number of stale requests + tolerated. Accepted range for this value is 1 – 2,147,483,647. Required + when defaultConsistencyPolicy is set to 'BoundedStaleness'. + :type max_staleness_prefix: long + :param max_interval_in_seconds: When used with the Bounded Staleness + consistency level, this value represents the time amount of staleness (in + seconds) tolerated. Accepted range for this value is 1 - 100. Required + when defaultConsistencyPolicy is set to 'BoundedStaleness'. + :type max_interval_in_seconds: int + """ + + _validation = { + 'default_consistency_level': {'required': True}, + 'max_staleness_prefix': {'maximum': 2147483647, 'minimum': 1}, + 'max_interval_in_seconds': {'maximum': 100, 'minimum': 1}, + } + + _attribute_map = { + 'default_consistency_level': {'key': 'defaultConsistencyLevel', 'type': 'DefaultConsistencyLevel'}, + 'max_staleness_prefix': {'key': 'maxStalenessPrefix', 'type': 'long'}, + 'max_interval_in_seconds': {'key': 'maxIntervalInSeconds', 'type': 'int'}, + } + + def __init__(self, default_consistency_level, max_staleness_prefix=None, max_interval_in_seconds=None): + self.default_consistency_level = default_consistency_level + self.max_staleness_prefix = max_staleness_prefix + self.max_interval_in_seconds = max_interval_in_seconds diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py new file mode 100644 index 00000000000..c815183e82d --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class DatabaseAccount(Resource): + """A DocumentDB database account. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The unique resource identifier of the database account. + :vartype id: str + :ivar name: The name of the database account. + :vartype name: str + :ivar type: The type of Azure resource. + :vartype type: str + :param location: The location of the resource group to which the resource + belongs. + :type location: str + :param tags: + :type tags: dict + :param kind: Indicates the type of database account. This can only be set + at database account creation. Possible values include: 'GlobalDocumentDB', + 'MongoDB', 'Parse'. Default value: "GlobalDocumentDB" . + :type kind: str or :class:`DatabaseAccountKind + ` + :param provisioning_state: + :type provisioning_state: str + :ivar document_endpoint: The connection endpoint for the DocumentDB + database account. + :vartype document_endpoint: str + :ivar database_account_offer_type: The offer type for the DocumentDB + database account. Default value: Standard. Possible values include: + 'Standard' + :vartype database_account_offer_type: str or + :class:`DatabaseAccountOfferType + ` + :param ip_range_filter: DocumentDB Firewall Support: This value 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. + :type ip_range_filter: str + :param consistency_policy: The consistency policy for the DocumentDB + database account. + :type consistency_policy: :class:`ConsistencyPolicy + ` + :ivar write_locations: An array that contains the write location for the + DocumentDB account. + :vartype write_locations: list of :class:`Location + ` + :ivar read_locations: An array that contains of the read locations enabled + for the DocumentDB account. + :vartype read_locations: list of :class:`Location + ` + :ivar failover_policies: An array that contains the regions ordered by + their failover priorities. + :vartype failover_policies: list of :class:`FailoverPolicy + ` + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'document_endpoint': {'readonly': True}, + 'database_account_offer_type': {'readonly': True}, + 'write_locations': {'readonly': True}, + 'read_locations': {'readonly': True}, + 'failover_policies': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'document_endpoint': {'key': 'properties.documentEndpoint', 'type': 'str'}, + 'database_account_offer_type': {'key': 'properties.databaseAccountOfferType', 'type': 'DatabaseAccountOfferType'}, + 'ip_range_filter': {'key': 'properties.ipRangeFilter', 'type': 'str'}, + 'consistency_policy': {'key': 'properties.consistencyPolicy', 'type': 'ConsistencyPolicy'}, + 'write_locations': {'key': 'properties.writeLocations', 'type': '[Location]'}, + 'read_locations': {'key': 'properties.readLocations', 'type': '[Location]'}, + 'failover_policies': {'key': 'properties.failoverPolicies', 'type': '[FailoverPolicy]'}, + } + + def __init__(self, location, tags=None, kind="GlobalDocumentDB", provisioning_state=None, ip_range_filter=None, consistency_policy=None): + super(DatabaseAccount, self).__init__(location=location, tags=tags) + self.kind = kind + self.provisioning_state = provisioning_state + self.document_endpoint = None + self.database_account_offer_type = None + self.ip_range_filter = ip_range_filter + self.consistency_policy = consistency_policy + self.write_locations = None + self.read_locations = None + self.failover_policies = None diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py new file mode 100644 index 00000000000..3aa2bf1c5ad --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class DatabaseAccountCreateUpdateParameters(Resource): + """Parameters to create and update DocumentDB database accounts. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The unique resource identifier of the database account. + :vartype id: str + :ivar name: The name of the database account. + :vartype name: str + :ivar type: The type of Azure resource. + :vartype type: str + :param location: The location of the resource group to which the resource + belongs. + :type location: str + :param tags: + :type tags: dict + :param consistency_policy: The consistency policy for the DocumentDB + account. + :type consistency_policy: :class:`ConsistencyPolicy + ` + :param locations: An array that contains the georeplication locations + enabled for the DocumentDB account. + :type locations: list of :class:`Location + ` + :ivar database_account_offer_type: Default value: "Standard" . + :vartype database_account_offer_type: str + :param ip_range_filter: DocumentDB Firewall Support: This value 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. + :type ip_range_filter: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'locations': {'required': True}, + 'database_account_offer_type': {'required': True, 'constant': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'consistency_policy': {'key': 'properties.consistencyPolicy', 'type': 'ConsistencyPolicy'}, + 'locations': {'key': 'properties.locations', 'type': '[Location]'}, + 'database_account_offer_type': {'key': 'properties.databaseAccountOfferType', 'type': 'str'}, + 'ip_range_filter': {'key': 'properties.ipRangeFilter', 'type': 'str'}, + } + + database_account_offer_type = "Standard" + + def __init__(self, location, locations, tags=None, consistency_policy=None, ip_range_filter=None): + super(DatabaseAccountCreateUpdateParameters, self).__init__(location=location, tags=tags) + self.consistency_policy = consistency_policy + self.locations = locations + self.ip_range_filter = ip_range_filter diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py new file mode 100644 index 00000000000..4d775054ac1 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DatabaseAccountListKeysResult(Model): + """The access keys for the given database account. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar primary_master_key: Base 64 encoded value of the primary read-write + key. + :vartype primary_master_key: str + :ivar secondary_master_key: Base 64 encoded value of the secondary + read-write key. + :vartype secondary_master_key: str + :ivar primary_readonly_master_key: Base 64 encoded value of the primary + read-only key. + :vartype primary_readonly_master_key: str + :ivar secondary_readonly_master_key: Base 64 encoded value of the + secondary read-only key. + :vartype secondary_readonly_master_key: str + """ + + _validation = { + 'primary_master_key': {'readonly': True}, + 'secondary_master_key': {'readonly': True}, + 'primary_readonly_master_key': {'readonly': True}, + 'secondary_readonly_master_key': {'readonly': True}, + } + + _attribute_map = { + 'primary_master_key': {'key': 'primaryMasterKey', 'type': 'str'}, + 'secondary_master_key': {'key': 'secondaryMasterKey', 'type': 'str'}, + 'primary_readonly_master_key': {'key': 'properties.primaryReadonlyMasterKey', 'type': 'str'}, + 'secondary_readonly_master_key': {'key': 'properties.secondaryReadonlyMasterKey', 'type': 'str'}, + } + + def __init__(self): + self.primary_master_key = None + self.secondary_master_key = None + self.primary_readonly_master_key = None + self.secondary_readonly_master_key = None diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py new file mode 100644 index 00000000000..3330353950c --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DatabaseAccountListReadOnlyKeysResult(Model): + """The read-only access keys for the given database account. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar primary_readonly_master_key: Base 64 encoded value of the primary + read-only key. + :vartype primary_readonly_master_key: str + :ivar secondary_readonly_master_key: Base 64 encoded value of the + secondary read-only key. + :vartype secondary_readonly_master_key: str + """ + + _validation = { + 'primary_readonly_master_key': {'readonly': True}, + 'secondary_readonly_master_key': {'readonly': True}, + } + + _attribute_map = { + 'primary_readonly_master_key': {'key': 'primaryReadonlyMasterKey', 'type': 'str'}, + 'secondary_readonly_master_key': {'key': 'secondaryReadonlyMasterKey', 'type': 'str'}, + } + + def __init__(self): + self.primary_readonly_master_key = None + self.secondary_readonly_master_key = None diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py new file mode 100644 index 00000000000..4cb94909c51 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class DatabaseAccountPaged(Paged): + """ + A paging container for iterating over a list of DatabaseAccount object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[DatabaseAccount]'} + } + + def __init__(self, *args, **kwargs): + + super(DatabaseAccountPaged, self).__init__(*args, **kwargs) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py new file mode 100644 index 00000000000..be78a4fd681 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DatabaseAccountPatchParameters(Model): + """Parameters for patching Azure DocumentDB database account properties. + + :param tags: + :type tags: dict + """ + + _validation = { + 'tags': {'required': True}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, tags): + self.tags = tags diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py new file mode 100644 index 00000000000..3bff90d33db --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DatabaseAccountRegenerateKeyParameters(Model): + """Parameters to regenerate the keys within the database account. + + :param key_kind: The access key to regenerate. Possible values include: + 'primary', 'secondary', 'primaryReadonly', 'secondaryReadonly' + :type key_kind: str or :class:`KeyKind + ` + """ + + _validation = { + 'key_kind': {'required': True}, + } + + _attribute_map = { + 'key_kind': {'key': 'keyKind', 'type': 'str'}, + } + + def __init__(self, key_kind): + self.key_kind = key_kind diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/document_db_enums.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/document_db_enums.py new file mode 100644 index 00000000000..fd3ffa372c6 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/document_db_enums.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class DatabaseAccountKind(Enum): + + global_document_db = "GlobalDocumentDB" + mongo_db = "MongoDB" + parse = "Parse" + + +class DatabaseAccountOfferType(Enum): + + standard = "Standard" + + +class DefaultConsistencyLevel(Enum): + + eventual = "Eventual" + session = "Session" + bounded_staleness = "BoundedStaleness" + strong = "Strong" + + +class KeyKind(Enum): + + primary = "primary" + secondary = "secondary" + primary_readonly = "primaryReadonly" + secondary_readonly = "secondaryReadonly" diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py new file mode 100644 index 00000000000..4c3ebff5e3b --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FailoverPolicies(Model): + """The list of new failover policies for the failover priority change. + + :param failover_policies: List of failover policies. + :type failover_policies: list of :class:`FailoverPolicy + ` + """ + + _attribute_map = { + 'failover_policies': {'key': 'failoverPolicies', 'type': '[FailoverPolicy]'}, + } + + def __init__(self, failover_policies=None): + self.failover_policies = failover_policies diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py new file mode 100644 index 00000000000..99cc2769403 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FailoverPolicy(Model): + """The failover policy for a given region of a database account. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The unique identifier of the region in which the database + account replicates to. Example: <accountName>-<locationName>. + :vartype id: str + :param location_name: The name of the region in which the database account + exists. + :type location_name: str + :param failover_priority: The failover priority of the region. A failover + priority of 0 indicates a write region. The maximum value for a failover + priority = (total number of regions - 1). Failover priority values must be + unique for each of the regions in which the database account exists. + :type failover_priority: int + """ + + _validation = { + 'id': {'readonly': True}, + 'failover_priority': {'minimum': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'location_name': {'key': 'locationName', 'type': 'str'}, + 'failover_priority': {'key': 'failoverPriority', 'type': 'int'}, + } + + def __init__(self, location_name=None, failover_priority=None): + self.id = None + self.location_name = location_name + self.failover_priority = failover_priority diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py new file mode 100644 index 00000000000..8bc82bde2c3 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Location(Model): + """A region in which the Azure DocumentDB database account is deployed. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The unique identifier of the region within the database account. + Example: <accountName>-<locationName>. + :vartype id: str + :param location_name: The name of the region. + :type location_name: str + :ivar document_endpoint: The connection endpoint for the specific region. + Example: + https://<accountName>-<locationName>.documents.azure.com:443/ + :vartype document_endpoint: str + :param provisioning_state: + :type provisioning_state: str + :param failover_priority: The failover priority of the region. A failover + priority of 0 indicates a write region. The maximum value for a failover + priority = (total number of regions - 1). Failover priority values must be + unique for each of the regions in which the database account exists. + :type failover_priority: int + """ + + _validation = { + 'id': {'readonly': True}, + 'document_endpoint': {'readonly': True}, + 'failover_priority': {'minimum': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'location_name': {'key': 'locationName', 'type': 'str'}, + 'document_endpoint': {'key': 'documentEndpoint', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'failover_priority': {'key': 'failoverPriority', 'type': 'int'}, + } + + def __init__(self, location_name=None, provisioning_state=None, failover_priority=None): + self.id = None + self.location_name = location_name + self.document_endpoint = None + self.provisioning_state = provisioning_state + self.failover_priority = failover_priority diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py new file mode 100644 index 00000000000..d5e887d0b78 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Resource(Model): + """A database account resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The unique resource identifier of the database account. + :vartype id: str + :ivar name: The name of the database account. + :vartype name: str + :ivar type: The type of Azure resource. + :vartype type: str + :param location: The location of the resource group to which the resource + belongs. + :type location: str + :param tags: + :type tags: dict + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, location, tags=None): + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py new file mode 100644 index 00000000000..27ed7c06953 --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .database_accounts_operations import DatabaseAccountsOperations + +__all__ = [ + 'DatabaseAccountsOperations', +] diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py new file mode 100644 index 00000000000..44e46d0f2be --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py @@ -0,0 +1,853 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError +from msrestazure.azure_operation import AzureOperationPoller +import uuid + +from .. import models + + +class DatabaseAccountsOperations(object): + """DatabaseAccountsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def get( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Retrieves the properties of an existing Azure DocumentDB database + account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: DocumentDB database account name. + :type account_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: :class:`DatabaseAccount + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('DatabaseAccount', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def patch( + self, resource_group_name, account_name, tags, custom_headers=None, raw=False, **operation_config): + """Patches the properties of an existing Azure DocumentDB database + account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: DocumentDB database account name. + :type account_name: str + :param tags: + :type tags: dict + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns :class:`DatabaseAccount + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + update_parameters = models.DatabaseAccountPatchParameters(tags=tags) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(update_parameters, 'DatabaseAccountPatchParameters') + + # Construct and send request + def long_running_send(): + + request = self._client.patch(url, query_parameters) + return self._client.send( + request, header_parameters, body_content, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('DatabaseAccount', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def create_or_update( + self, resource_group_name, account_name, create_update_parameters, custom_headers=None, raw=False, **operation_config): + """Creates or updates an Azure DocumentDB database account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: DocumentDB database account name. + :type account_name: str + :param create_update_parameters: The parameters to provide for the + current database account. + :type create_update_parameters: + :class:`DatabaseAccountCreateUpdateParameters + ` + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns :class:`DatabaseAccount + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(create_update_parameters, 'DatabaseAccountCreateUpdateParameters') + + # Construct and send request + def long_running_send(): + + request = self._client.put(url, query_parameters) + return self._client.send( + request, header_parameters, body_content, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('DatabaseAccount', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def delete( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Deletes an existing Azure DocumentDB database account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: DocumentDB database account name. + :type account_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns None + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + def long_running_send(): + + request = self._client.delete(url, query_parameters) + return self._client.send(request, header_parameters, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [202, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def failover_priority_change( + self, resource_group_name, account_name, failover_policies=None, custom_headers=None, raw=False, **operation_config): + """Changes the failover priority for the Azure DocumentDB database + account. A failover priority of 0 indicates a write region. The maximum + value for a failover priority = (total number of regions - 1). Failover + priority values must be unique for each of the regions in which the + database account exists. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: DocumentDB database account name. + :type account_name: str + :param failover_policies: List of failover policies. + :type failover_policies: list of :class:`FailoverPolicy + ` + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns None + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + failover_parameters = models.FailoverPolicies(failover_policies=failover_policies) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(failover_parameters, 'FailoverPolicies') + + # Construct and send request + def long_running_send(): + + request = self._client.post(url, query_parameters) + return self._client.send( + request, header_parameters, body_content, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [202, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Lists all the Azure DocumentDB database accounts available under the + subscription. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: :class:`DatabaseAccountPaged + ` + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + deserialized = models.DatabaseAccountPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.DatabaseAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def list_by_resource_group( + self, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Lists all the Azure DocumentDB database accounts available under the + given resource group. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: :class:`DatabaseAccountPaged + ` + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + deserialized = models.DatabaseAccountPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.DatabaseAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def list_keys( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Lists the access keys for the specified Azure DocumentDB database + account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: DocumentDB database account name. + :type account_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: :class:`DatabaseAccountListKeysResult + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('DatabaseAccountListKeysResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def list_read_only_keys( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Lists the read-only access keys for the specified Azure DocumentDB + database account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: DocumentDB database account name. + :type account_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: :class:`DatabaseAccountListReadOnlyKeysResult + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('DatabaseAccountListReadOnlyKeysResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def regenerate_key( + self, resource_group_name, account_name, key_kind, custom_headers=None, raw=False, **operation_config): + """Regenerates an access key for the specified Azure DocumentDB database + account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: DocumentDB database account name. + :type account_name: str + :param key_kind: The access key to regenerate. Possible values + include: 'primary', 'secondary', 'primaryReadonly', + 'secondaryReadonly' + :type key_kind: str or :class:`KeyKind + ` + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns None + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + key_to_regenerate = models.DatabaseAccountRegenerateKeyParameters(key_kind=key_kind) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(key_to_regenerate, 'DatabaseAccountRegenerateKeyParameters') + + # Construct and send request + def long_running_send(): + + request = self._client.post(url, query_parameters) + return self._client.send( + request, header_parameters, body_content, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def check_name_exists( + self, account_name, custom_headers=None, raw=False, **operation_config): + """Checks that the Azure DocumentDB account name already exists. A valid + account name may contain only lowercase letters, numbers, and the '-' + character, and must be between 3 and 50 characters. + + :param account_name: DocumentDB database account name. + :type account_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: bool + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}' + path_format_arguments = { + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.head(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200, 404]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = (response.status_code == 200) + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + return deserialized diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py new file mode 100644 index 00000000000..e0ec669828c --- /dev/null +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" + diff --git a/src/command_modules/azure-cli-documentdb/setup.py b/src/command_modules/azure-cli-documentdb/setup.py index a7b164b5c32..591d3b0451e 100644 --- a/src/command_modules/azure-cli-documentdb/setup.py +++ b/src/command_modules/azure-cli-documentdb/setup.py @@ -27,7 +27,6 @@ ] DEPENDENCIES = [ - 'azure-mgmt-documentdb==1.0.0', 'azure-cli-core', ] @@ -39,7 +38,7 @@ setup( name='azure-cli-documentdb', version=VERSION, - description='Microsoft Azure Command-Line Tools documentdb Command Module', + description='Microsoft Azure Command-Line Tools DocumentDB Command Module', long_description=README + '\n\n' + HISTORY, license='MIT', author='Microsoft Corporation', From 4674dedd464ab15fcd1b655d19a03694b5ef5487 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Fri, 20 Jan 2017 18:43:37 -0800 Subject: [PATCH 03/15] create command completed --- .../cli/command_modules/documentdb/_help.py | 22 +--- .../cli/command_modules/documentdb/_params.py | 31 +++-- .../command_modules/documentdb/commands.py | 12 +- .../cli/command_modules/documentdb/custom.py | 112 +++++++----------- 4 files changed, 69 insertions(+), 108 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py index ef3a8ed294a..25308451c08 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py @@ -11,24 +11,4 @@ type: group short-summary: Managed NoSQL Database long-summary: -""" - -# helps['documentdb export'] = """ -# type: command -# short-summary: Export data stored in a documentdb cache. -# """ - -# helps['documentdb import-method'] = """ -# type: command -# short-summary: Import data into a documentdb cache. -# """ - -# helps['documentdb update-settings'] = """ -# type: command -# short-summary: Update the settings of a documentdb cache. -# """ - -# helps['documentdb patch-schedule'] = """ -# type: group -# short-summary: Commands to manage documentdb patch schedules -# """ \ No newline at end of file +""" \ No newline at end of file diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index eaca896a858..2a850c8e2da 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -12,22 +12,39 @@ import azure.cli.core.commands.arm # pylint: disable=unused-import from azure.cli.core.commands import CliArgumentType from azure.cli.command_modules.documentdb.sdk.models.document_db_enums import KeyKind +from azure.cli.command_modules.documentdb.sdk.models.document_db_enums import DefaultConsistencyLevel from azure.cli.command_modules.documentdb.sdk.models.failover_policy import FailoverPolicy +from azure.cli.command_modules.documentdb.sdk.models.location import Location +from azure.cli.command_modules.documentdb.sdk.models.location import Location def validate_failover_policies(ns): ''' Extracts multiple space-separated failoverPolcies in region=failoverPriority format ''' - tags_dict = [] + fp_dict = [] for item in ns.failover_policies: - print(item) comps = item.split('=', 1) - tags_dict.append(FailoverPolicy(comps[0], int(comps[1]))) - ns.failover_policies = tags_dict + fp_dict.append(FailoverPolicy(comps[0], int(comps[1]))) + ns.failover_policies = fp_dict return ns +def validate_locations(ns): + ''' Extracts multiple space-separated locations in regionName=failoverPriority format ''' + 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 + return ns -register_cli_argument('documentdb', 'account_name', arg_type=name_type, help='name of the DocumentDB Database Account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part="name") +register_cli_argument('documentdb', 'account_name', arg_type=name_type, help='Name of the DocumentDB Database Account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part="name") register_cli_argument('documentdb regenerate-key', 'key_kind', **enum_choice_list(KeyKind)) -register_cli_argument('documentdb failover-priority-change', 'failover_policies', validator=validate_failover_policies, help="space separated failover policies in 'region=failoverPriority' format. E.g \"East US\"=0", nargs='+') -# register_cli_argument('documentdb create', ) \ No newline at end of file +register_cli_argument('documentdb failover-priority-change', 'failover_policies', validator=validate_failover_policies, help="space separated failover policies in 'regionName=failoverPriority' format. E.g \"East US\"=0", nargs='+') + +register_cli_argument('documentdb create', 'resource_group_location', help="location of the resource group") +register_cli_argument('documentdb create', 'locations', validator=validate_locations, help="space separated locations in 'regionName=failoverPriority' format. E.g \"East US\"=0", nargs='+') +register_cli_argument('documentdb create', 'default_consistency_level', help="default consistency level", **enum_choice_list(DefaultConsistencyLevel)) +register_cli_argument('documentdb create', 'resource_group_location', help="location of the resource group") +register_cli_argument('documentdb create', 'max_staleness_prefix', help="maximum staleness prefix", type=int) +register_cli_argument('documentdb create', 'max_interval_in_seconds', help="max_interval_in_seconds", type=int) +register_cli_argument('documentdb create', 'ip_range_filter', help="IP Range Filter") diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py index cfed6fd2457..8fa6ca19915 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py @@ -18,14 +18,4 @@ cli_command(__name__, 'documentdb check-name-exists', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.check_name_exists', cf_documentdb) cli_command(__name__, 'documentdb delete', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.delete', cf_documentdb) cli_command(__name__, 'documentdb failover-priority-change', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.failover_priority_change', cf_documentdb) -cli_command(__name__, 'documentdb create', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.create_or_update', cf_documentdb) - -#createOrUpdate remember to add laurents fix -#failoverpriorityChange - -# cli_command(__name__, 'documentdb create', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_create', cf_documentdb) -# cli_command(__name__, 'documentdb export', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_export', cf_documentdb) -# cli_command(__name__, 'documentdb force-reboot', 'azure.cli.command_modules.documentdb.sdk.operations.documentdb_operations#documentdbOperations.force_reboot', cf_documentdb) -# cli_command(__name__, 'documentdb import-method', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_import_method', cf_documentdb) -# cli_command(__name__, 'documentdb regenerate-keys', 'azure.cli.command_modules.documentdb.sdk.operations.documentdb_operations#documentdbOperations.regenerate_key', cf_documentdb) -# cli_command(__name__, 'documentdb update-settings', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_update_settings', cf_documentdb) +cli_command(__name__, 'documentdb create', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_create', cf_documentdb) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index 3d061b942c9..fa9aedaaba7 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -3,72 +3,46 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -# from azure.cli.command_modules.documentdb.sdk.models import ( -# # ImportRDBParameters, -# # ExportRDBParameters, -# # documentdbCreateOrUpdateParameters, -# # Sku, -# ) - -# def cli_documentdb_export(client, resource_group_name, name, prefix, container, file_format=None): -# # pylint:disable=too-many-arguments -# parameters = ExportRDBParameters(prefix, container, file_format) -# return client.export(resource_group_name, name, parameters) - -# def cli_documentdb_import_method(client, resource_group_name, name, file_format, files): -# parameters = ImportRDBParameters(files, file_format) -# return client.import_method(resource_group_name, name, files, parameters) - -# def cli_documentdb_update_settings(client, resource_group_name, name, documentdb_configuration): -# existing = client.get(resource_group_name, name) -# existing.documentdb_configuration.update(documentdb_configuration) - -# # Due to swagger/mgmt SDK quirkiness, we have to manually copy over -# # the resource retrieved to a create_or_update_parameters object -# update_params = documentdbCreateOrUpdateParameters( -# existing.location, -# existing.sku, -# existing.tags, -# existing.documentdb_version, -# existing.documentdb_configuration, -# existing.enable_non_ssl_port, -# existing.tenant_settings, -# existing.shard_count, -# existing.subnet_id, -# existing.static_ip, -# ) -# return client.create_or_update(resource_group_name, name, parameters=update_params) - -# def cli_documentdb_create(client, resource_group_name, name, location, sku_name, # pylint:disable=too-many-arguments -# sku_family, sku_capacity, tags=None, documentdb_configuration=None, -# enable_non_ssl_port=None, tenant_settings=None, shard_count=None, -# subnet_id=None, static_ip=None): -# # pylint:disable=line-too-long -# """Create new documentdb Cache instance -# :param resource_group_name: Name of resource group -# :param name: Name of documentdb cache -# :param location: Location -# :param sku_name: What type of documentdb cache to deploy. Valid values: (Basic, Standard, Premium). -# :param sku_family: Which family to use. Valid values: (C, P). -# :param sku_capacity: What size of documentdb cache to deploy. Valid values for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4) -# :param documentdb_configuration: All documentdb Settings. Few possible keys rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set-max-intset-entries, zset-max-ziplist-entries, zset-max-ziplist-value etc. -# :param enable_non_ssl_port: If the value is true, then the non-ssl documentdb server port (6379) will be enabled. -# :param tenant_settings: Json dictionary with tenant settings -# :param shard_count: The number of shards to be created on a Premium Cluster Cache. -# :param subnet_id: The full resource ID of a subnet in a virtual network to deploy the documentdb cache in. Example format /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1 -# :param static_ip: Required when deploying a documentdb cache inside an existing Azure Virtual Network. -# """ -# params = documentdbCreateOrUpdateParameters( -# location, -# Sku(sku_name, sku_family, sku_capacity), -# tags, -# None, # Version is deprecated and ignored -# documentdb_configuration, -# enable_non_ssl_port, -# tenant_settings, -# shard_count, -# subnet_id, -# static_ip) - -# return client.create_or_update(resource_group_name, name, params) - +# --locations +# -ipRangeFilter +# -defaultConsistencyLevel +# - MaxIntervalInSeconds +# - MaxStalenessPrefix +# - resource-group-location +# -Kind + +from azure.cli.command_modules.documentdb.sdk.models import ( + ConsistencyPolicy, + DatabaseAccountCreateUpdateParameters, + DatabaseAccountKind, + DatabaseAccountOfferType, + DefaultConsistencyLevel, + Location +) + +def cli_documentdb_create(client, + resource_group_name, + name, + resource_group_location, + locations, + default_consistency_level=None, + max_staleness_prefix=100, + max_interval_in_seconds=5, + ip_range_filter=None): + # pylint:disable=line-too-long + """Create new DocumentDB Database Account + :param resource_group_name: Name of resource group + :param name: Name of DocumentDB Database Account + :param location: Resource group location + """ + consistency_policy = None + if not default_consistency_level is None: + consistency_policy = ConsistencyPolicy(default_consistency_level, max_staleness_prefix, max_interval_in_seconds) + + params = DatabaseAccountCreateUpdateParameters( + resource_group_location, + locations, + consistency_policy=consistency_policy, + ip_range_filter=ip_range_filter) + + return client.database_accounts.create_or_update(resource_group_name, name, params) \ No newline at end of file From 58dbd316962ca6234978a5de90c57ae6e6138b3f Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Fri, 27 Jan 2017 13:48:36 -0800 Subject: [PATCH 04/15] Addressed PR comments --- .../cli/command_modules/documentdb/_help.py | 3 +-- .../cli/command_modules/documentdb/_params.py | 19 +++++++++--------- .../command_modules/documentdb/commands.py | 20 ++++++++++--------- .../cli/command_modules/documentdb/custom.py | 16 ++++++++------- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py index 25308451c08..95d2901111e 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_help.py @@ -9,6 +9,5 @@ helps['documentdb'] = """ type: group - short-summary: Managed NoSQL Database - long-summary: + short-summary: Commands to manage your Azure DocumentDB (NoSQL) database accounts. """ \ No newline at end of file diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index 2a850c8e2da..b8c097732ab 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -7,7 +7,8 @@ from azure.cli.core.commands.parameters import ( get_resource_name_completion_list, enum_choice_list, - name_type) + name_type, + ignore_type) from azure.cli.core.commands import register_cli_argument import azure.cli.core.commands.arm # pylint: disable=unused-import from azure.cli.core.commands import CliArgumentType @@ -15,7 +16,6 @@ from azure.cli.command_modules.documentdb.sdk.models.document_db_enums import DefaultConsistencyLevel from azure.cli.command_modules.documentdb.sdk.models.failover_policy import FailoverPolicy from azure.cli.command_modules.documentdb.sdk.models.location import Location -from azure.cli.command_modules.documentdb.sdk.models.location import Location def validate_failover_policies(ns): @@ -25,7 +25,6 @@ def validate_failover_policies(ns): comps = item.split('=', 1) fp_dict.append(FailoverPolicy(comps[0], int(comps[1]))) ns.failover_policies = fp_dict - return ns def validate_locations(ns): ''' Extracts multiple space-separated locations in regionName=failoverPriority format ''' @@ -34,17 +33,17 @@ def validate_locations(ns): comps = item.split('=', 1) loc_dict.append(Location(location_name=comps[0], failover_priority=int(comps[1]))) ns.locations = loc_dict - return ns register_cli_argument('documentdb', 'account_name', arg_type=name_type, help='Name of the DocumentDB Database Account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part="name") register_cli_argument('documentdb regenerate-key', 'key_kind', **enum_choice_list(KeyKind)) register_cli_argument('documentdb failover-priority-change', 'failover_policies', validator=validate_failover_policies, help="space separated failover policies in 'regionName=failoverPriority' format. E.g \"East US\"=0", nargs='+') -register_cli_argument('documentdb create', 'resource_group_location', help="location of the resource group") +register_cli_argument('documentdb create', 'account_name', completer=None) +register_cli_argument('documentdb create', 'resource_group_name', help="name of the resource group") +register_cli_argument('documentdb create', 'resource_group_location', ignore_type, help="location of the resource group") register_cli_argument('documentdb create', 'locations', validator=validate_locations, help="space separated locations in 'regionName=failoverPriority' format. E.g \"East US\"=0", nargs='+') -register_cli_argument('documentdb create', 'default_consistency_level', help="default consistency level", **enum_choice_list(DefaultConsistencyLevel)) -register_cli_argument('documentdb create', 'resource_group_location', help="location of the resource group") -register_cli_argument('documentdb create', 'max_staleness_prefix', help="maximum staleness prefix", type=int) -register_cli_argument('documentdb create', 'max_interval_in_seconds', help="max_interval_in_seconds", type=int) -register_cli_argument('documentdb create', 'ip_range_filter', help="IP Range Filter") +register_cli_argument('documentdb create', 'default_consistency_level', help="default consistency level of the DocumentDB Database account", **enum_choice_list(DefaultConsistencyLevel)) +register_cli_argument('documentdb 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('documentdb 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('documentdb create', 'ip_range_filter', help="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") diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py index 8fa6ca19915..5fd4052f80c 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py @@ -9,13 +9,15 @@ import azure.cli.command_modules.documentdb from azure.cli.command_modules.documentdb._client_factory import (cf_documentdb) -cli_command(__name__, 'documentdb show', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.get', cf_documentdb) -cli_command(__name__, 'documentdb list', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.list_by_resource_group', cf_documentdb) -cli_command(__name__, 'documentdb list-all', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.list', cf_documentdb) -cli_command(__name__, 'documentdb list-keys', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.list_keys', cf_documentdb) -cli_command(__name__, 'documentdb list-read-only-keys', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.list_read_only_keys', cf_documentdb) -cli_command(__name__, 'documentdb regenerate-key', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.regenerate_key', cf_documentdb) -cli_command(__name__, 'documentdb check-name-exists', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.check_name_exists', cf_documentdb) -cli_command(__name__, 'documentdb delete', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.delete', cf_documentdb) -cli_command(__name__, 'documentdb failover-priority-change', 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#DatabaseAccountsOperations.failover_priority_change', cf_documentdb) +custom_path = 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#{}' + +cli_command(__name__, 'documentdb show', custom_path.format('DatabaseAccountsOperations.get'), cf_documentdb) +cli_command(__name__, 'documentdb list', custom_path.format('DatabaseAccountsOperations.list_by_resource_group'), cf_documentdb) +cli_command(__name__, 'documentdb list-all', custom_path.format('DatabaseAccountsOperations.list'), cf_documentdb) +cli_command(__name__, 'documentdb list-keys', custom_path.format('DatabaseAccountsOperations.list_keys'), cf_documentdb) +cli_command(__name__, 'documentdb list-read-only-keys', custom_path.format('DatabaseAccountsOperations.list_read_only_keys'), cf_documentdb) +cli_command(__name__, 'documentdb regenerate-key', custom_path.format('DatabaseAccountsOperations.regenerate_key'), cf_documentdb) +cli_command(__name__, 'documentdb check-name-exists', custom_path.format('DatabaseAccountsOperations.check_name_exists'), cf_documentdb) +cli_command(__name__, 'documentdb delete', custom_path.format('DatabaseAccountsOperations.delete'), cf_documentdb) +cli_command(__name__, 'documentdb failover-priority-change', custom_path.format('DatabaseAccountsOperations.failover_priority_change'), cf_documentdb) cli_command(__name__, 'documentdb create', 'azure.cli.command_modules.documentdb.custom#cli_documentdb_create', cf_documentdb) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index fa9aedaaba7..c2633c00673 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -23,22 +23,24 @@ def cli_documentdb_create(client, resource_group_name, name, - resource_group_location, locations, default_consistency_level=None, max_staleness_prefix=100, max_interval_in_seconds=5, ip_range_filter=None): # pylint:disable=line-too-long - """Create new DocumentDB Database Account - :param resource_group_name: Name of resource group - :param name: Name of DocumentDB Database Account - :param location: Resource group location - """ + consistency_policy = None - if not default_consistency_level is None: + if default_consistency_level is not None: consistency_policy = ConsistencyPolicy(default_consistency_level, max_staleness_prefix, max_interval_in_seconds) + resource_client = get_mgmt_service_client(ResourceManagementClient) + + from azure.mgmt.resource.resources import ResourceManagementClient + from azure.cli.core.commands.client_factory import get_mgmt_service_client + rg = resource_client.resource_groups.get(resource_group_name) + resource_group_location = rg.location # pylint: disable=no-member + params = DatabaseAccountCreateUpdateParameters( resource_group_location, locations, From 093aca9fff478a76564d298a7bb1f3f12cfa6e78 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Fri, 27 Jan 2017 13:49:43 -0800 Subject: [PATCH 05/15] import ResourceManagementClient before using --- .../azure/cli/command_modules/documentdb/custom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index c2633c00673..9f3438b69d4 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -34,10 +34,10 @@ def cli_documentdb_create(client, if default_consistency_level is not None: consistency_policy = ConsistencyPolicy(default_consistency_level, max_staleness_prefix, max_interval_in_seconds) - resource_client = get_mgmt_service_client(ResourceManagementClient) - + from azure.mgmt.resource.resources import ResourceManagementClient from azure.cli.core.commands.client_factory import get_mgmt_service_client + resource_client = get_mgmt_service_client(ResourceManagementClient) rg = resource_client.resource_groups.get(resource_group_name) resource_group_location = rg.location # pylint: disable=no-member From e47f7e8a9acc183d573862e1e58d892d6b365679 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Fri, 27 Jan 2017 13:52:47 -0800 Subject: [PATCH 06/15] fixed linter warnings --- .../azure/cli/command_modules/documentdb/_params.py | 1 - .../azure/cli/command_modules/documentdb/commands.py | 1 - .../azure/cli/command_modules/documentdb/custom.py | 4 ---- 3 files changed, 6 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index b8c097732ab..892cd484748 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -11,7 +11,6 @@ ignore_type) from azure.cli.core.commands import register_cli_argument import azure.cli.core.commands.arm # pylint: disable=unused-import -from azure.cli.core.commands import CliArgumentType from azure.cli.command_modules.documentdb.sdk.models.document_db_enums import KeyKind from azure.cli.command_modules.documentdb.sdk.models.document_db_enums import DefaultConsistencyLevel from azure.cli.command_modules.documentdb.sdk.models.failover_policy import FailoverPolicy diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py index 5fd4052f80c..db4fd911331 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py @@ -6,7 +6,6 @@ #pylint: disable=line-too-long from azure.cli.core.commands import cli_command -import azure.cli.command_modules.documentdb from azure.cli.command_modules.documentdb._client_factory import (cf_documentdb) custom_path = 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#{}' diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index 9f3438b69d4..934cdcd7609 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -14,10 +14,6 @@ from azure.cli.command_modules.documentdb.sdk.models import ( ConsistencyPolicy, DatabaseAccountCreateUpdateParameters, - DatabaseAccountKind, - DatabaseAccountOfferType, - DefaultConsistencyLevel, - Location ) def cli_documentdb_create(client, From ed792ffd8b24a5ce51cfb77d5d12b052d44846e0 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Fri, 27 Jan 2017 14:20:34 -0800 Subject: [PATCH 07/15] fixed help output --- .../azure/cli/command_modules/documentdb/_params.py | 4 ++-- .../azure/cli/command_modules/documentdb/custom.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index 892cd484748..5de30497db7 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -41,8 +41,8 @@ def validate_locations(ns): register_cli_argument('documentdb create', 'account_name', completer=None) register_cli_argument('documentdb create', 'resource_group_name', help="name of the resource group") register_cli_argument('documentdb create', 'resource_group_location', ignore_type, help="location of the resource group") -register_cli_argument('documentdb create', 'locations', validator=validate_locations, help="space separated locations in 'regionName=failoverPriority' format. E.g \"East US\"=0", nargs='+') +register_cli_argument('documentdb create', '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('documentdb create', 'default_consistency_level', help="default consistency level of the DocumentDB Database account", **enum_choice_list(DefaultConsistencyLevel)) register_cli_argument('documentdb 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('documentdb 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('documentdb create', 'ip_range_filter', help="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") +register_cli_argument('documentdb create', '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") diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index 934cdcd7609..4068ee988e7 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -18,13 +18,15 @@ def cli_documentdb_create(client, resource_group_name, - name, + account_name, locations, default_consistency_level=None, max_staleness_prefix=100, - max_interval_in_seconds=5, + max_interval=5, ip_range_filter=None): # pylint:disable=line-too-long + """Create a new Azure DocumentDB database account. + """ consistency_policy = None if default_consistency_level is not None: From d191e3dd739f4745e34210638ab739967e6c5913 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Fri, 27 Jan 2017 14:34:19 -0800 Subject: [PATCH 08/15] fixed additional linter errors --- .../azure/cli/command_modules/documentdb/custom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index 4068ee988e7..12be6dc874f 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -30,7 +30,7 @@ def cli_documentdb_create(client, consistency_policy = None if default_consistency_level is not None: - consistency_policy = ConsistencyPolicy(default_consistency_level, max_staleness_prefix, max_interval_in_seconds) + consistency_policy = ConsistencyPolicy(default_consistency_level, max_staleness_prefix, max_interval) from azure.mgmt.resource.resources import ResourceManagementClient @@ -45,4 +45,4 @@ def cli_documentdb_create(client, consistency_policy=consistency_policy, ip_range_filter=ip_range_filter) - return client.database_accounts.create_or_update(resource_group_name, name, params) \ No newline at end of file + return client.database_accounts.create_or_update(resource_group_name, account_name, params) From fdaf9d5b6b1520ac0a473ebe7dc887c480ee3cf9 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Mon, 30 Jan 2017 12:18:35 -0800 Subject: [PATCH 09/15] removed help for resource_group_location and added validation for ip range fitler --- .../azure/cli/command_modules/documentdb/_params.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index 5de30497db7..477f2910220 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -33,6 +33,9 @@ def validate_locations(ns): loc_dict.append(Location(location_name=comps[0], failover_priority=int(comps[1]))) ns.locations = loc_dict +def validate_ip_range_filter(ns): + ns.ip_range_filter = ",".join(ns.ip_range_filter.split()) + register_cli_argument('documentdb', 'account_name', arg_type=name_type, help='Name of the DocumentDB Database Account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part="name") register_cli_argument('documentdb regenerate-key', 'key_kind', **enum_choice_list(KeyKind)) @@ -40,9 +43,9 @@ def validate_locations(ns): register_cli_argument('documentdb create', 'account_name', completer=None) register_cli_argument('documentdb create', 'resource_group_name', help="name of the resource group") -register_cli_argument('documentdb create', 'resource_group_location', ignore_type, help="location of the resource group") +register_cli_argument('documentdb create', 'resource_group_location', ignore_type) register_cli_argument('documentdb create', '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('documentdb create', 'default_consistency_level', help="default consistency level of the DocumentDB Database account", **enum_choice_list(DefaultConsistencyLevel)) register_cli_argument('documentdb 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('documentdb 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('documentdb create', '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") +register_cli_argument('documentdb 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") From d5e6ee80089664b3753310b0e7ed6a45bc03b4a5 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Mon, 30 Jan 2017 12:47:25 -0800 Subject: [PATCH 10/15] null check ip_range_filter --- .../azure/cli/command_modules/documentdb/_params.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index 477f2910220..3e5bc216f01 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -34,7 +34,8 @@ def validate_locations(ns): ns.locations = loc_dict def validate_ip_range_filter(ns): - ns.ip_range_filter = ",".join(ns.ip_range_filter.split()) + if ns.ip_range_filter: + ns.ip_range_filter = ",".join(ns.ip_range_filter.split()) register_cli_argument('documentdb', 'account_name', arg_type=name_type, help='Name of the DocumentDB Database Account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part="name") From 9840144796534543762a3c2668ab049a9cdc6aa2 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Mon, 30 Jan 2017 14:01:19 -0800 Subject: [PATCH 11/15] added multiple arguments capability to ip range filter --- .../azure/cli/command_modules/documentdb/_params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index 3e5bc216f01..349dce83ac4 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -35,7 +35,7 @@ def validate_locations(ns): def validate_ip_range_filter(ns): if ns.ip_range_filter: - ns.ip_range_filter = ",".join(ns.ip_range_filter.split()) + ns.ip_range_filter = ",".join(ns.ip_range_filter) register_cli_argument('documentdb', 'account_name', arg_type=name_type, help='Name of the DocumentDB Database Account', completer=get_resource_name_completion_list('Microsoft.DocumentDb/databaseAccounts'), id_part="name") @@ -49,4 +49,4 @@ def validate_ip_range_filter(ns): register_cli_argument('documentdb create', 'default_consistency_level', help="default consistency level of the DocumentDB Database account", **enum_choice_list(DefaultConsistencyLevel)) register_cli_argument('documentdb 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('documentdb 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('documentdb 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") +register_cli_argument('documentdb 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='+') From aafe5c3a0e04fc4b3dd07a7c26cd1a7156576253 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Tue, 31 Jan 2017 13:43:14 -0800 Subject: [PATCH 12/15] fixed pylint errors --- .../azure/cli/command_modules/documentdb/_params.py | 2 +- .../azure/cli/command_modules/documentdb/custom.py | 1 + .../azure/cli/command_modules/documentdb/sdk/document_db.py | 1 + .../command_modules/documentdb/sdk/models/consistency_policy.py | 1 + .../command_modules/documentdb/sdk/models/database_account.py | 1 + .../sdk/models/database_account_create_update_parameters.py | 1 + .../documentdb/sdk/models/database_account_list_keys_result.py | 1 + .../sdk/models/database_account_list_read_only_keys_result.py | 1 + .../documentdb/sdk/models/database_account_paged.py | 1 + .../documentdb/sdk/models/database_account_patch_parameters.py | 1 + .../sdk/models/database_account_regenerate_key_parameters.py | 1 + .../command_modules/documentdb/sdk/models/failover_policies.py | 1 + .../command_modules/documentdb/sdk/models/failover_policy.py | 1 + .../azure/cli/command_modules/documentdb/sdk/models/location.py | 1 + .../azure/cli/command_modules/documentdb/sdk/models/resource.py | 1 + .../cli/command_modules/documentdb/sdk/operations/__init__.py | 1 + .../documentdb/sdk/operations/database_accounts_operations.py | 1 + .../azure/cli/command_modules/documentdb/sdk/version.py | 1 + 18 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index 349dce83ac4..00dde90ada5 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -18,7 +18,7 @@ def validate_failover_policies(ns): - ''' Extracts multiple space-separated failoverPolcies in region=failoverPriority format ''' + ''' Extracts multiple space-separated failoverPolicies in regionName=failoverPriority format ''' fp_dict = [] for item in ns.failover_policies: comps = item.split('=', 1) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index 12be6dc874f..51f4deef037 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -16,6 +16,7 @@ DatabaseAccountCreateUpdateParameters, ) +# pylint:disable=too-many-arguments def cli_documentdb_create(client, resource_group_name, account_name, diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py index 804d09ed34e..a087026abcd 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.service_client import ServiceClient from msrest import Serializer, Deserializer diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py index fae7c28a59a..358fa2add4b 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py index c815183e82d..3324ae902d5 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from .resource import Resource diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py index 3aa2bf1c5ad..e8e3720e41f 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from .resource import Resource diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py index 4d775054ac1..38d2a26ca56 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py index 3330353950c..cb721f9bdca 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py index 4cb94909c51..7643ab4d7f8 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.paging import Paged diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py index be78a4fd681..db4c26a614a 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py index 3bff90d33db..27f23b27cfd 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py index 4c3ebff5e3b..80ab2d1a8a1 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py index 99cc2769403..7b5dee58699 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py index 8bc82bde2c3..6f3e5021678 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py index d5e887d0b78..9267d839c89 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.serialization import Model diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py index 27ed7c06953..c561de365fa 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from .database_accounts_operations import DatabaseAccountsOperations diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py index 44e46d0f2be..3c3fd9e7548 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py index e0ec669828c..a0a06c92ae5 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py @@ -8,6 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: skip-file VERSION = "0.1.0" From d3668c0caad097bee9bf231ee8ba64a2cfd061f0 Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Wed, 1 Feb 2017 09:36:41 -0800 Subject: [PATCH 13/15] perform a get on database account after create completes --- .../azure/cli/command_modules/documentdb/custom.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index 51f4deef037..dac52e9d59c 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -46,4 +46,7 @@ def cli_documentdb_create(client, consistency_policy=consistency_policy, ip_range_filter=ip_range_filter) - return client.database_accounts.create_or_update(resource_group_name, account_name, params) + async_docdb_create = client.database_accounts.create_or_update(resource_group_name, account_name, params) + docdb_account = async_docdb_create.result() # Will be empty, shouldn't + docdb_account = client.database_accounts.get(resource_group_name, account_name) # Workaround + return docdb_account From 8fa859ca520edf3746cc9d0ff4bcae1d3a9ebb4e Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Wed, 1 Feb 2017 11:01:39 -0800 Subject: [PATCH 14/15] use documentdb pypi package instead --- .../documentdb/_client_factory.py | 2 +- .../cli/command_modules/documentdb/_params.py | 8 +- .../command_modules/documentdb/commands.py | 2 +- .../cli/command_modules/documentdb/custom.py | 2 +- .../documentdb/sdk/__init__.py | 18 - .../documentdb/sdk/document_db.py | 119 --- .../documentdb/sdk/models/__init__.py | 48 - .../sdk/models/consistency_policy.py | 51 -- .../documentdb/sdk/models/database_account.py | 111 --- ...tabase_account_create_update_parameters.py | 77 -- .../database_account_list_keys_result.py | 54 -- ...base_account_list_read_only_keys_result.py | 42 - .../sdk/models/database_account_paged.py | 28 - .../database_account_patch_parameters.py | 32 - ...abase_account_regenerate_key_parameters.py | 34 - .../sdk/models/document_db_enums.py | 40 - .../sdk/models/failover_policies.py | 29 - .../documentdb/sdk/models/failover_policy.py | 49 - .../documentdb/sdk/models/location.py | 59 -- .../documentdb/sdk/models/resource.py | 55 -- .../documentdb/sdk/operations/__init__.py | 17 - .../database_accounts_operations.py | 854 ------------------ .../command_modules/documentdb/sdk/version.py | 14 - .../azure-cli-documentdb/setup.py | 3 +- 24 files changed, 9 insertions(+), 1739 deletions(-) delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/__init__.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/__init__.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/document_db_enums.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py delete mode 100644 src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py index 72def8e1823..1d80f0cfc44 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_client_factory.py @@ -5,5 +5,5 @@ def cf_documentdb(_): from azure.cli.core.commands.client_factory import get_mgmt_service_client - from azure.cli.command_modules.documentdb.sdk import DocumentDB + from azure.mgmt.documentdb import DocumentDB return get_mgmt_service_client(DocumentDB) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py index 00dde90ada5..6f9f4072118 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/_params.py @@ -11,10 +11,10 @@ ignore_type) from azure.cli.core.commands import register_cli_argument import azure.cli.core.commands.arm # pylint: disable=unused-import -from azure.cli.command_modules.documentdb.sdk.models.document_db_enums import KeyKind -from azure.cli.command_modules.documentdb.sdk.models.document_db_enums import DefaultConsistencyLevel -from azure.cli.command_modules.documentdb.sdk.models.failover_policy import FailoverPolicy -from azure.cli.command_modules.documentdb.sdk.models.location import Location +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.failover_policy import FailoverPolicy +from azure.mgmt.documentdb.models.location import Location def validate_failover_policies(ns): diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py index db4fd911331..2782fc6e92a 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/commands.py @@ -8,7 +8,7 @@ from azure.cli.core.commands import cli_command from azure.cli.command_modules.documentdb._client_factory import (cf_documentdb) -custom_path = 'azure.cli.command_modules.documentdb.sdk.operations.database_accounts_operations#{}' +custom_path = 'azure.mgmt.documentdb.operations.database_accounts_operations#{}' cli_command(__name__, 'documentdb show', custom_path.format('DatabaseAccountsOperations.get'), cf_documentdb) cli_command(__name__, 'documentdb list', custom_path.format('DatabaseAccountsOperations.list_by_resource_group'), cf_documentdb) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py index dac52e9d59c..3775ed24c87 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/custom.py @@ -11,7 +11,7 @@ # - resource-group-location # -Kind -from azure.cli.command_modules.documentdb.sdk.models import ( +from azure.mgmt.documentdb.models import ( ConsistencyPolicy, DatabaseAccountCreateUpdateParameters, ) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/__init__.py deleted file mode 100644 index 3ec900145f1..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .document_db import DocumentDB -from .version import VERSION - -__all__ = ['DocumentDB'] - -__version__ = VERSION - diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py deleted file mode 100644 index a087026abcd..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/document_db.py +++ /dev/null @@ -1,119 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.service_client import ServiceClient -from msrest import Serializer, Deserializer -from msrestazure import AzureConfiguration -from .version import VERSION -from .operations.database_accounts_operations import DatabaseAccountsOperations -from . import models - - -class DocumentDBConfiguration(AzureConfiguration): - """Configuration for DocumentDB - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Azure subscription ID. - :type subscription_id: str - :param api_version: Version of the API to be used with the client request. - The current version is 2015-04-08. - :type api_version: str - :param accept_language: Gets or sets the preferred language for the - response. - :type accept_language: str - :param long_running_operation_retry_timeout: Gets or sets the retry - timeout in seconds for Long Running Operations. Default value is 30. - :type long_running_operation_retry_timeout: int - :param generate_client_request_id: When set to true a unique - x-ms-client-request-id value is generated and included in each request. - Default is true. - :type generate_client_request_id: bool - :param str base_url: Service URL - :param str filepath: Existing config - """ - - def __init__( - self, credentials, subscription_id, api_version='2015-04-08', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - if not isinstance(subscription_id, str): - raise TypeError("Parameter 'subscription_id' must be str.") - if api_version is not None and not isinstance(api_version, str): - raise TypeError("Optional parameter 'api_version' must be str.") - if accept_language is not None and not isinstance(accept_language, str): - raise TypeError("Optional parameter 'accept_language' must be str.") - if not base_url: - base_url = 'https://management.azure.com' - - super(DocumentDBConfiguration, self).__init__(base_url, filepath) - - self.add_user_agent('documentdb/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials - self.subscription_id = subscription_id - self.api_version = api_version - self.accept_language = accept_language - self.long_running_operation_retry_timeout = long_running_operation_retry_timeout - self.generate_client_request_id = generate_client_request_id - - -class DocumentDB(object): - """Azure DocumentDB Database Service Resource Provider REST API - - :ivar config: Configuration for client. - :vartype config: DocumentDBConfiguration - - :ivar database_accounts: DatabaseAccounts operations - :vartype database_accounts: .operations.DatabaseAccountsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Azure subscription ID. - :type subscription_id: str - :param api_version: Version of the API to be used with the client request. - The current version is 2015-04-08. - :type api_version: str - :param accept_language: Gets or sets the preferred language for the - response. - :type accept_language: str - :param long_running_operation_retry_timeout: Gets or sets the retry - timeout in seconds for Long Running Operations. Default value is 30. - :type long_running_operation_retry_timeout: int - :param generate_client_request_id: When set to true a unique - x-ms-client-request-id value is generated and included in each request. - Default is true. - :type generate_client_request_id: bool - :param str base_url: Service URL - :param str filepath: Existing config - """ - - def __init__( - self, credentials, subscription_id, api_version='2015-04-08', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - - self.config = DocumentDBConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) - self._client = ServiceClient(self.config.credentials, self.config) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.database_accounts = DatabaseAccountsOperations( - self._client, self.config, self._serialize, self._deserialize) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/__init__.py deleted file mode 100644 index af5d37cf1c8..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/__init__.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .consistency_policy import ConsistencyPolicy -from .location import Location -from .failover_policy import FailoverPolicy -from .database_account import DatabaseAccount -from .failover_policies import FailoverPolicies -from .resource import Resource -from .database_account_create_update_parameters import DatabaseAccountCreateUpdateParameters -from .database_account_patch_parameters import DatabaseAccountPatchParameters -from .database_account_list_read_only_keys_result import DatabaseAccountListReadOnlyKeysResult -from .database_account_list_keys_result import DatabaseAccountListKeysResult -from .database_account_regenerate_key_parameters import DatabaseAccountRegenerateKeyParameters -from .database_account_paged import DatabaseAccountPaged -from .document_db_enums import ( - DatabaseAccountKind, - DatabaseAccountOfferType, - DefaultConsistencyLevel, - KeyKind, -) - -__all__ = [ - 'ConsistencyPolicy', - 'Location', - 'FailoverPolicy', - 'DatabaseAccount', - 'FailoverPolicies', - 'Resource', - 'DatabaseAccountCreateUpdateParameters', - 'DatabaseAccountPatchParameters', - 'DatabaseAccountListReadOnlyKeysResult', - 'DatabaseAccountListKeysResult', - 'DatabaseAccountRegenerateKeyParameters', - 'DatabaseAccountPaged', - 'DatabaseAccountKind', - 'DatabaseAccountOfferType', - 'DefaultConsistencyLevel', - 'KeyKind', -] diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py deleted file mode 100644 index 358fa2add4b..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/consistency_policy.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class ConsistencyPolicy(Model): - """The consistency policy for the DocumentDB database account. - - :param default_consistency_level: The default consistency level and - configuration settings of the DocumentDB account. Possible values include: - 'Eventual', 'Session', 'BoundedStaleness', 'Strong' - :type default_consistency_level: str or :class:`DefaultConsistencyLevel - ` - :param max_staleness_prefix: When used with the Bounded Staleness - consistency level, this value represents the number of stale requests - tolerated. Accepted range for this value is 1 – 2,147,483,647. Required - when defaultConsistencyPolicy is set to 'BoundedStaleness'. - :type max_staleness_prefix: long - :param max_interval_in_seconds: When used with the Bounded Staleness - consistency level, this value represents the time amount of staleness (in - seconds) tolerated. Accepted range for this value is 1 - 100. Required - when defaultConsistencyPolicy is set to 'BoundedStaleness'. - :type max_interval_in_seconds: int - """ - - _validation = { - 'default_consistency_level': {'required': True}, - 'max_staleness_prefix': {'maximum': 2147483647, 'minimum': 1}, - 'max_interval_in_seconds': {'maximum': 100, 'minimum': 1}, - } - - _attribute_map = { - 'default_consistency_level': {'key': 'defaultConsistencyLevel', 'type': 'DefaultConsistencyLevel'}, - 'max_staleness_prefix': {'key': 'maxStalenessPrefix', 'type': 'long'}, - 'max_interval_in_seconds': {'key': 'maxIntervalInSeconds', 'type': 'int'}, - } - - def __init__(self, default_consistency_level, max_staleness_prefix=None, max_interval_in_seconds=None): - self.default_consistency_level = default_consistency_level - self.max_staleness_prefix = max_staleness_prefix - self.max_interval_in_seconds = max_interval_in_seconds diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py deleted file mode 100644 index 3324ae902d5..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from .resource import Resource - - -class DatabaseAccount(Resource): - """A DocumentDB database account. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: The unique resource identifier of the database account. - :vartype id: str - :ivar name: The name of the database account. - :vartype name: str - :ivar type: The type of Azure resource. - :vartype type: str - :param location: The location of the resource group to which the resource - belongs. - :type location: str - :param tags: - :type tags: dict - :param kind: Indicates the type of database account. This can only be set - at database account creation. Possible values include: 'GlobalDocumentDB', - 'MongoDB', 'Parse'. Default value: "GlobalDocumentDB" . - :type kind: str or :class:`DatabaseAccountKind - ` - :param provisioning_state: - :type provisioning_state: str - :ivar document_endpoint: The connection endpoint for the DocumentDB - database account. - :vartype document_endpoint: str - :ivar database_account_offer_type: The offer type for the DocumentDB - database account. Default value: Standard. Possible values include: - 'Standard' - :vartype database_account_offer_type: str or - :class:`DatabaseAccountOfferType - ` - :param ip_range_filter: DocumentDB Firewall Support: This value 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. - :type ip_range_filter: str - :param consistency_policy: The consistency policy for the DocumentDB - database account. - :type consistency_policy: :class:`ConsistencyPolicy - ` - :ivar write_locations: An array that contains the write location for the - DocumentDB account. - :vartype write_locations: list of :class:`Location - ` - :ivar read_locations: An array that contains of the read locations enabled - for the DocumentDB account. - :vartype read_locations: list of :class:`Location - ` - :ivar failover_policies: An array that contains the regions ordered by - their failover priorities. - :vartype failover_policies: list of :class:`FailoverPolicy - ` - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'document_endpoint': {'readonly': True}, - 'database_account_offer_type': {'readonly': True}, - 'write_locations': {'readonly': True}, - 'read_locations': {'readonly': True}, - 'failover_policies': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'document_endpoint': {'key': 'properties.documentEndpoint', 'type': 'str'}, - 'database_account_offer_type': {'key': 'properties.databaseAccountOfferType', 'type': 'DatabaseAccountOfferType'}, - 'ip_range_filter': {'key': 'properties.ipRangeFilter', 'type': 'str'}, - 'consistency_policy': {'key': 'properties.consistencyPolicy', 'type': 'ConsistencyPolicy'}, - 'write_locations': {'key': 'properties.writeLocations', 'type': '[Location]'}, - 'read_locations': {'key': 'properties.readLocations', 'type': '[Location]'}, - 'failover_policies': {'key': 'properties.failoverPolicies', 'type': '[FailoverPolicy]'}, - } - - def __init__(self, location, tags=None, kind="GlobalDocumentDB", provisioning_state=None, ip_range_filter=None, consistency_policy=None): - super(DatabaseAccount, self).__init__(location=location, tags=tags) - self.kind = kind - self.provisioning_state = provisioning_state - self.document_endpoint = None - self.database_account_offer_type = None - self.ip_range_filter = ip_range_filter - self.consistency_policy = consistency_policy - self.write_locations = None - self.read_locations = None - self.failover_policies = None diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py deleted file mode 100644 index e8e3720e41f..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_create_update_parameters.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from .resource import Resource - - -class DatabaseAccountCreateUpdateParameters(Resource): - """Parameters to create and update DocumentDB database accounts. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: The unique resource identifier of the database account. - :vartype id: str - :ivar name: The name of the database account. - :vartype name: str - :ivar type: The type of Azure resource. - :vartype type: str - :param location: The location of the resource group to which the resource - belongs. - :type location: str - :param tags: - :type tags: dict - :param consistency_policy: The consistency policy for the DocumentDB - account. - :type consistency_policy: :class:`ConsistencyPolicy - ` - :param locations: An array that contains the georeplication locations - enabled for the DocumentDB account. - :type locations: list of :class:`Location - ` - :ivar database_account_offer_type: Default value: "Standard" . - :vartype database_account_offer_type: str - :param ip_range_filter: DocumentDB Firewall Support: This value 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. - :type ip_range_filter: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'locations': {'required': True}, - 'database_account_offer_type': {'required': True, 'constant': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'consistency_policy': {'key': 'properties.consistencyPolicy', 'type': 'ConsistencyPolicy'}, - 'locations': {'key': 'properties.locations', 'type': '[Location]'}, - 'database_account_offer_type': {'key': 'properties.databaseAccountOfferType', 'type': 'str'}, - 'ip_range_filter': {'key': 'properties.ipRangeFilter', 'type': 'str'}, - } - - database_account_offer_type = "Standard" - - def __init__(self, location, locations, tags=None, consistency_policy=None, ip_range_filter=None): - super(DatabaseAccountCreateUpdateParameters, self).__init__(location=location, tags=tags) - self.consistency_policy = consistency_policy - self.locations = locations - self.ip_range_filter = ip_range_filter diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py deleted file mode 100644 index 38d2a26ca56..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_keys_result.py +++ /dev/null @@ -1,54 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class DatabaseAccountListKeysResult(Model): - """The access keys for the given database account. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar primary_master_key: Base 64 encoded value of the primary read-write - key. - :vartype primary_master_key: str - :ivar secondary_master_key: Base 64 encoded value of the secondary - read-write key. - :vartype secondary_master_key: str - :ivar primary_readonly_master_key: Base 64 encoded value of the primary - read-only key. - :vartype primary_readonly_master_key: str - :ivar secondary_readonly_master_key: Base 64 encoded value of the - secondary read-only key. - :vartype secondary_readonly_master_key: str - """ - - _validation = { - 'primary_master_key': {'readonly': True}, - 'secondary_master_key': {'readonly': True}, - 'primary_readonly_master_key': {'readonly': True}, - 'secondary_readonly_master_key': {'readonly': True}, - } - - _attribute_map = { - 'primary_master_key': {'key': 'primaryMasterKey', 'type': 'str'}, - 'secondary_master_key': {'key': 'secondaryMasterKey', 'type': 'str'}, - 'primary_readonly_master_key': {'key': 'properties.primaryReadonlyMasterKey', 'type': 'str'}, - 'secondary_readonly_master_key': {'key': 'properties.secondaryReadonlyMasterKey', 'type': 'str'}, - } - - def __init__(self): - self.primary_master_key = None - self.secondary_master_key = None - self.primary_readonly_master_key = None - self.secondary_readonly_master_key = None diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py deleted file mode 100644 index cb721f9bdca..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_list_read_only_keys_result.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class DatabaseAccountListReadOnlyKeysResult(Model): - """The read-only access keys for the given database account. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar primary_readonly_master_key: Base 64 encoded value of the primary - read-only key. - :vartype primary_readonly_master_key: str - :ivar secondary_readonly_master_key: Base 64 encoded value of the - secondary read-only key. - :vartype secondary_readonly_master_key: str - """ - - _validation = { - 'primary_readonly_master_key': {'readonly': True}, - 'secondary_readonly_master_key': {'readonly': True}, - } - - _attribute_map = { - 'primary_readonly_master_key': {'key': 'primaryReadonlyMasterKey', 'type': 'str'}, - 'secondary_readonly_master_key': {'key': 'secondaryReadonlyMasterKey', 'type': 'str'}, - } - - def __init__(self): - self.primary_readonly_master_key = None - self.secondary_readonly_master_key = None diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py deleted file mode 100644 index 7643ab4d7f8..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_paged.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.paging import Paged - - -class DatabaseAccountPaged(Paged): - """ - A paging container for iterating over a list of DatabaseAccount object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DatabaseAccount]'} - } - - def __init__(self, *args, **kwargs): - - super(DatabaseAccountPaged, self).__init__(*args, **kwargs) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py deleted file mode 100644 index db4c26a614a..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_patch_parameters.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class DatabaseAccountPatchParameters(Model): - """Parameters for patching Azure DocumentDB database account properties. - - :param tags: - :type tags: dict - """ - - _validation = { - 'tags': {'required': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__(self, tags): - self.tags = tags diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py deleted file mode 100644 index 27f23b27cfd..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/database_account_regenerate_key_parameters.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class DatabaseAccountRegenerateKeyParameters(Model): - """Parameters to regenerate the keys within the database account. - - :param key_kind: The access key to regenerate. Possible values include: - 'primary', 'secondary', 'primaryReadonly', 'secondaryReadonly' - :type key_kind: str or :class:`KeyKind - ` - """ - - _validation = { - 'key_kind': {'required': True}, - } - - _attribute_map = { - 'key_kind': {'key': 'keyKind', 'type': 'str'}, - } - - def __init__(self, key_kind): - self.key_kind = key_kind diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/document_db_enums.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/document_db_enums.py deleted file mode 100644 index fd3ffa372c6..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/document_db_enums.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum - - -class DatabaseAccountKind(Enum): - - global_document_db = "GlobalDocumentDB" - mongo_db = "MongoDB" - parse = "Parse" - - -class DatabaseAccountOfferType(Enum): - - standard = "Standard" - - -class DefaultConsistencyLevel(Enum): - - eventual = "Eventual" - session = "Session" - bounded_staleness = "BoundedStaleness" - strong = "Strong" - - -class KeyKind(Enum): - - primary = "primary" - secondary = "secondary" - primary_readonly = "primaryReadonly" - secondary_readonly = "secondaryReadonly" diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py deleted file mode 100644 index 80ab2d1a8a1..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policies.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class FailoverPolicies(Model): - """The list of new failover policies for the failover priority change. - - :param failover_policies: List of failover policies. - :type failover_policies: list of :class:`FailoverPolicy - ` - """ - - _attribute_map = { - 'failover_policies': {'key': 'failoverPolicies', 'type': '[FailoverPolicy]'}, - } - - def __init__(self, failover_policies=None): - self.failover_policies = failover_policies diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py deleted file mode 100644 index 7b5dee58699..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/failover_policy.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class FailoverPolicy(Model): - """The failover policy for a given region of a database account. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: The unique identifier of the region in which the database - account replicates to. Example: <accountName>-<locationName>. - :vartype id: str - :param location_name: The name of the region in which the database account - exists. - :type location_name: str - :param failover_priority: The failover priority of the region. A failover - priority of 0 indicates a write region. The maximum value for a failover - priority = (total number of regions - 1). Failover priority values must be - unique for each of the regions in which the database account exists. - :type failover_priority: int - """ - - _validation = { - 'id': {'readonly': True}, - 'failover_priority': {'minimum': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'location_name': {'key': 'locationName', 'type': 'str'}, - 'failover_priority': {'key': 'failoverPriority', 'type': 'int'}, - } - - def __init__(self, location_name=None, failover_priority=None): - self.id = None - self.location_name = location_name - self.failover_priority = failover_priority diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py deleted file mode 100644 index 6f3e5021678..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/location.py +++ /dev/null @@ -1,59 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class Location(Model): - """A region in which the Azure DocumentDB database account is deployed. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: The unique identifier of the region within the database account. - Example: <accountName>-<locationName>. - :vartype id: str - :param location_name: The name of the region. - :type location_name: str - :ivar document_endpoint: The connection endpoint for the specific region. - Example: - https://<accountName>-<locationName>.documents.azure.com:443/ - :vartype document_endpoint: str - :param provisioning_state: - :type provisioning_state: str - :param failover_priority: The failover priority of the region. A failover - priority of 0 indicates a write region. The maximum value for a failover - priority = (total number of regions - 1). Failover priority values must be - unique for each of the regions in which the database account exists. - :type failover_priority: int - """ - - _validation = { - 'id': {'readonly': True}, - 'document_endpoint': {'readonly': True}, - 'failover_priority': {'minimum': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'location_name': {'key': 'locationName', 'type': 'str'}, - 'document_endpoint': {'key': 'documentEndpoint', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'failover_priority': {'key': 'failoverPriority', 'type': 'int'}, - } - - def __init__(self, location_name=None, provisioning_state=None, failover_priority=None): - self.id = None - self.location_name = location_name - self.document_endpoint = None - self.provisioning_state = provisioning_state - self.failover_priority = failover_priority diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py deleted file mode 100644 index 9267d839c89..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/models/resource.py +++ /dev/null @@ -1,55 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.serialization import Model - - -class Resource(Model): - """A database account resource. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: The unique resource identifier of the database account. - :vartype id: str - :ivar name: The name of the database account. - :vartype name: str - :ivar type: The type of Azure resource. - :vartype type: str - :param location: The location of the resource group to which the resource - belongs. - :type location: str - :param tags: - :type tags: dict - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__(self, location, tags=None): - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py deleted file mode 100644 index c561de365fa..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from .database_accounts_operations import DatabaseAccountsOperations - -__all__ = [ - 'DatabaseAccountsOperations', -] diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py deleted file mode 100644 index 3c3fd9e7548..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/operations/database_accounts_operations.py +++ /dev/null @@ -1,854 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrestazure.azure_operation import AzureOperationPoller -import uuid - -from .. import models - - -class DatabaseAccountsOperations(object): - """DatabaseAccountsOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An objec model deserializer. - """ - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - - self.config = config - - def get( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Retrieves the properties of an existing Azure DocumentDB database - account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: DocumentDB database account name. - :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :rtype: :class:`DatabaseAccount - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('DatabaseAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def patch( - self, resource_group_name, account_name, tags, custom_headers=None, raw=False, **operation_config): - """Patches the properties of an existing Azure DocumentDB database - account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: DocumentDB database account name. - :type account_name: str - :param tags: - :type tags: dict - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :rtype: - :class:`AzureOperationPoller` - instance that returns :class:`DatabaseAccount - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - update_parameters = models.DatabaseAccountPatchParameters(tags=tags) - - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(update_parameters, 'DatabaseAccountPatchParameters') - - # Construct and send request - def long_running_send(): - - request = self._client.patch(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) - - def get_long_running_status(status_link, headers=None): - - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) - - def get_long_running_output(response): - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('DatabaseAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - if raw: - response = long_running_send() - return get_long_running_output(response) - - long_running_operation_timeout = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - return AzureOperationPoller( - long_running_send, get_long_running_output, - get_long_running_status, long_running_operation_timeout) - - def create_or_update( - self, resource_group_name, account_name, create_update_parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates an Azure DocumentDB database account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: DocumentDB database account name. - :type account_name: str - :param create_update_parameters: The parameters to provide for the - current database account. - :type create_update_parameters: - :class:`DatabaseAccountCreateUpdateParameters - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :rtype: - :class:`AzureOperationPoller` - instance that returns :class:`DatabaseAccount - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(create_update_parameters, 'DatabaseAccountCreateUpdateParameters') - - # Construct and send request - def long_running_send(): - - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) - - def get_long_running_status(status_link, headers=None): - - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) - - def get_long_running_output(response): - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('DatabaseAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - if raw: - response = long_running_send() - return get_long_running_output(response) - - long_running_operation_timeout = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - return AzureOperationPoller( - long_running_send, get_long_running_output, - get_long_running_status, long_running_operation_timeout) - - def delete( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Deletes an existing Azure DocumentDB database account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: DocumentDB database account name. - :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :rtype: - :class:`AzureOperationPoller` - instance that returns None - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - def long_running_send(): - - request = self._client.delete(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) - - def get_long_running_status(status_link, headers=None): - - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) - - def get_long_running_output(response): - - if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - if raw: - response = long_running_send() - return get_long_running_output(response) - - long_running_operation_timeout = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - return AzureOperationPoller( - long_running_send, get_long_running_output, - get_long_running_status, long_running_operation_timeout) - - def failover_priority_change( - self, resource_group_name, account_name, failover_policies=None, custom_headers=None, raw=False, **operation_config): - """Changes the failover priority for the Azure DocumentDB database - account. A failover priority of 0 indicates a write region. The maximum - value for a failover priority = (total number of regions - 1). Failover - priority values must be unique for each of the regions in which the - database account exists. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: DocumentDB database account name. - :type account_name: str - :param failover_policies: List of failover policies. - :type failover_policies: list of :class:`FailoverPolicy - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :rtype: - :class:`AzureOperationPoller` - instance that returns None - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - failover_parameters = models.FailoverPolicies(failover_policies=failover_policies) - - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(failover_parameters, 'FailoverPolicies') - - # Construct and send request - def long_running_send(): - - request = self._client.post(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) - - def get_long_running_status(status_link, headers=None): - - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) - - def get_long_running_output(response): - - if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - if raw: - response = long_running_send() - return get_long_running_output(response) - - long_running_operation_timeout = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - return AzureOperationPoller( - long_running_send, get_long_running_output, - get_long_running_status, long_running_operation_timeout) - - def list( - self, custom_headers=None, raw=False, **operation_config): - """Lists all the Azure DocumentDB database accounts available under the - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :rtype: :class:`DatabaseAccountPaged - ` - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - deserialized = models.DatabaseAccountPaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.DatabaseAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - - def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): - """Lists all the Azure DocumentDB database accounts available under the - given resource group. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :rtype: :class:`DatabaseAccountPaged - ` - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - deserialized = models.DatabaseAccountPaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.DatabaseAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - - def list_keys( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Lists the access keys for the specified Azure DocumentDB database - account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: DocumentDB database account name. - :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :rtype: :class:`DatabaseAccountListKeysResult - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('DatabaseAccountListKeysResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def list_read_only_keys( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Lists the read-only access keys for the specified Azure DocumentDB - database account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: DocumentDB database account name. - :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :rtype: :class:`DatabaseAccountListReadOnlyKeysResult - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('DatabaseAccountListReadOnlyKeysResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def regenerate_key( - self, resource_group_name, account_name, key_kind, custom_headers=None, raw=False, **operation_config): - """Regenerates an access key for the specified Azure DocumentDB database - account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: DocumentDB database account name. - :type account_name: str - :param key_kind: The access key to regenerate. Possible values - include: 'primary', 'secondary', 'primaryReadonly', - 'secondaryReadonly' - :type key_kind: str or :class:`KeyKind - ` - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :rtype: - :class:`AzureOperationPoller` - instance that returns None - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - key_to_regenerate = models.DatabaseAccountRegenerateKeyParameters(key_kind=key_kind) - - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern='^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(key_to_regenerate, 'DatabaseAccountRegenerateKeyParameters') - - # Construct and send request - def long_running_send(): - - request = self._client.post(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) - - def get_long_running_status(status_link, headers=None): - - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) - - def get_long_running_output(response): - - if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - if raw: - response = long_running_send() - return get_long_running_output(response) - - long_running_operation_timeout = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - return AzureOperationPoller( - long_running_send, get_long_running_output, - get_long_running_status, long_running_operation_timeout) - - def check_name_exists( - self, account_name, custom_headers=None, raw=False, **operation_config): - """Checks that the Azure DocumentDB account name already exists. A valid - account name may contain only lowercase letters, numbers, and the '-' - character, and must be between 3 and 50 characters. - - :param account_name: DocumentDB database account name. - :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :rtype: bool - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: :class:`CloudError` - """ - # Construct URL - url = '/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}' - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.head(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 200) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py deleted file mode 100644 index a0a06c92ae5..00000000000 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/sdk/version.py +++ /dev/null @@ -1,14 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: skip-file - -VERSION = "0.1.0" - diff --git a/src/command_modules/azure-cli-documentdb/setup.py b/src/command_modules/azure-cli-documentdb/setup.py index 591d3b0451e..d8b649ac7ff 100644 --- a/src/command_modules/azure-cli-documentdb/setup.py +++ b/src/command_modules/azure-cli-documentdb/setup.py @@ -27,7 +27,8 @@ ] DEPENDENCIES = [ - 'azure-cli-core', + 'azure-mgmt-documentdb==0.1.0', + 'azure-cli-core' ] with open('README.rst', 'r', encoding='utf-8') as f: From ea338733b705374ddedae52cd6fad6a951b3223d Mon Sep 17 00:00:00 2001 From: Digvijay Makwana Date: Wed, 1 Feb 2017 11:15:50 -0800 Subject: [PATCH 15/15] cleared test --- .../tests/test_documentdb_params.py | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/test_documentdb_params.py b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/test_documentdb_params.py index 335cb21bde7..34913fb394d 100644 --- a/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/test_documentdb_params.py +++ b/src/command_modules/azure-cli-documentdb/azure/cli/command_modules/documentdb/tests/test_documentdb_params.py @@ -2,45 +2,3 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- - -import unittest - -from azure.cli.core.application import APPLICATION, Configuration - -def mock_echo_args(command_name, parameters): - try: - argv = ' '.join((command_name, parameters)).split() - APPLICATION.initialize(Configuration(argv)) - command_table = APPLICATION.configuration.get_command_table() - prefunc = command_table[command_name].handler - command_table[command_name].handler = lambda args: args - parsed_namespace = APPLICATION.execute(argv) - return parsed_namespace - finally: - command_table[command_name].handler = prefunc - -class Test_documentdbCache(unittest.TestCase): - - @classmethod - def setUpClass(cls): - pass - - def test_parse_documentdb_create(self): - - args = mock_echo_args('documentdb create', - '--tenant-settings {\"hello\":1} -g wombat -n asldkj --sku-family c -l westus --sku-capacity 1 --sku-name basic') # pylint: disable=line-too-long - subset = set(dict( - sku_family='C', - sku_capacity='1', - sku_name='Basic', - name='asldkj' - ).items()) - - superset = set([(k, v) for k, v in args.result.items() if not isinstance(v, dict)]) - - self.assertTrue( - subset.issubset(superset) - ) - - tenant_settings = dict(hello=1) - self.assertDictEqual(tenant_settings, args.result['tenant_settings'])