diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/HISTORY.rst b/sdk/cosmos/azure-mgmt-cosmosdb/HISTORY.rst index 22fbd73029cd..584cff5df350 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/HISTORY.rst +++ b/sdk/cosmos/azure-mgmt-cosmosdb/HISTORY.rst @@ -3,6 +3,30 @@ Release History =============== +0.7.0 (2019-06-07) +++++++++++++++++++ + +**Features** + +- Added operation DatabaseAccountsOperations.get_gremlin_graph_throughput +- Added operation DatabaseAccountsOperations.get_sql_database_throughput +- Added operation DatabaseAccountsOperations.update_gremlin_database_throughput +- Added operation DatabaseAccountsOperations.get_sql_container_throughput +- Added operation DatabaseAccountsOperations.update_sql_container_throughput +- Added operation DatabaseAccountsOperations.get_gremlin_database_throughput +- Added operation DatabaseAccountsOperations.get_cassandra_table_throughput +- Added operation DatabaseAccountsOperations.update_cassandra_keyspace_throughput +- Added operation DatabaseAccountsOperations.update_mongo_db_collection_throughput +- Added operation DatabaseAccountsOperations.update_cassandra_table_throughput +- Added operation DatabaseAccountsOperations.update_table_throughput +- Added operation DatabaseAccountsOperations.update_mongo_db_database_throughput +- Added operation DatabaseAccountsOperations.get_mongo_db_database_throughput +- Added operation DatabaseAccountsOperations.update_sql_database_throughput +- Added operation DatabaseAccountsOperations.get_table_throughput +- Added operation DatabaseAccountsOperations.get_mongo_db_collection_throughput +- Added operation DatabaseAccountsOperations.update_gremlin_graph_throughput +- Added operation DatabaseAccountsOperations.get_cassandra_keyspace_throughput + 0.6.1 (2019-05-31) ++++++++++++++++++ diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/__init__.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/__init__.py index fdad0dbc2e3d..a3cc095a4f19 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/__init__.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/__init__.py @@ -38,6 +38,7 @@ from .region_for_online_offline_py3 import RegionForOnlineOffline from .resource_py3 import Resource from .extended_resource_properties_py3 import ExtendedResourceProperties + from .throughput_py3 import Throughput from .database_account_create_update_parameters_py3 import DatabaseAccountCreateUpdateParameters from .database_account_patch_parameters_py3 import DatabaseAccountPatchParameters from .database_account_list_read_only_keys_result_py3 import DatabaseAccountListReadOnlyKeysResult @@ -45,6 +46,8 @@ from .database_account_connection_string_py3 import DatabaseAccountConnectionString from .database_account_list_connection_strings_result_py3 import DatabaseAccountListConnectionStringsResult from .database_account_regenerate_key_parameters_py3 import DatabaseAccountRegenerateKeyParameters + from .throughput_resource_py3 import ThroughputResource + from .throughput_update_parameters_py3 import ThroughputUpdateParameters from .sql_database_resource_py3 import SqlDatabaseResource from .sql_database_create_update_parameters_py3 import SqlDatabaseCreateUpdateParameters from .sql_container_resource_py3 import SqlContainerResource @@ -111,6 +114,7 @@ from .region_for_online_offline import RegionForOnlineOffline from .resource import Resource from .extended_resource_properties import ExtendedResourceProperties + from .throughput import Throughput 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 @@ -118,6 +122,8 @@ from .database_account_connection_string import DatabaseAccountConnectionString from .database_account_list_connection_strings_result import DatabaseAccountListConnectionStringsResult from .database_account_regenerate_key_parameters import DatabaseAccountRegenerateKeyParameters + from .throughput_resource import ThroughputResource + from .throughput_update_parameters import ThroughputUpdateParameters from .sql_database_resource import SqlDatabaseResource from .sql_database_create_update_parameters import SqlDatabaseCreateUpdateParameters from .sql_container_resource import SqlContainerResource @@ -215,6 +221,7 @@ 'RegionForOnlineOffline', 'Resource', 'ExtendedResourceProperties', + 'Throughput', 'DatabaseAccountCreateUpdateParameters', 'DatabaseAccountPatchParameters', 'DatabaseAccountListReadOnlyKeysResult', @@ -222,6 +229,8 @@ 'DatabaseAccountConnectionString', 'DatabaseAccountListConnectionStringsResult', 'DatabaseAccountRegenerateKeyParameters', + 'ThroughputResource', + 'ThroughputUpdateParameters', 'SqlDatabaseResource', 'SqlDatabaseCreateUpdateParameters', 'SqlContainerResource', diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput.py new file mode 100644 index 000000000000..40aa89e8adce --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput.py @@ -0,0 +1,56 @@ +# 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 Throughput(Resource): + """An Azure Cosmos DB resource throughput. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :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[str, str] + :param throughput: Required. Value of the Cosmos DB resource throughput + :type throughput: int + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'throughput': {'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}'}, + 'throughput': {'key': 'properties.throughput', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(Throughput, self).__init__(**kwargs) + self.throughput = kwargs.get('throughput', None) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_py3.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_py3.py new file mode 100644 index 000000000000..6ed7d4252424 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_py3.py @@ -0,0 +1,56 @@ +# 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_py3 import Resource + + +class Throughput(Resource): + """An Azure Cosmos DB resource throughput. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :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[str, str] + :param throughput: Required. Value of the Cosmos DB resource throughput + :type throughput: int + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'throughput': {'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}'}, + 'throughput': {'key': 'properties.throughput', 'type': 'int'}, + } + + def __init__(self, *, throughput: int, location: str=None, tags=None, **kwargs) -> None: + super(Throughput, self).__init__(location=location, tags=tags, **kwargs) + self.throughput = throughput diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_resource.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_resource.py new file mode 100644 index 000000000000..e3a44627755c --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_resource.py @@ -0,0 +1,34 @@ +# 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 ThroughputResource(Model): + """Cosmos DB resource throughput object. + + All required parameters must be populated in order to send to Azure. + + :param throughput: Required. Value of the Cosmos DB resource throughput + :type throughput: int + """ + + _validation = { + 'throughput': {'required': True}, + } + + _attribute_map = { + 'throughput': {'key': 'throughput', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(ThroughputResource, self).__init__(**kwargs) + self.throughput = kwargs.get('throughput', None) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_resource_py3.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_resource_py3.py new file mode 100644 index 000000000000..e44bb9b13544 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_resource_py3.py @@ -0,0 +1,34 @@ +# 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 ThroughputResource(Model): + """Cosmos DB resource throughput object. + + All required parameters must be populated in order to send to Azure. + + :param throughput: Required. Value of the Cosmos DB resource throughput + :type throughput: int + """ + + _validation = { + 'throughput': {'required': True}, + } + + _attribute_map = { + 'throughput': {'key': 'throughput', 'type': 'int'}, + } + + def __init__(self, *, throughput: int, **kwargs) -> None: + super(ThroughputResource, self).__init__(**kwargs) + self.throughput = throughput diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_update_parameters.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_update_parameters.py new file mode 100644 index 000000000000..8a1e3aa91df1 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_update_parameters.py @@ -0,0 +1,35 @@ +# 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 ThroughputUpdateParameters(Model): + """Parameters to update Cosmos DB resource throughput. + + All required parameters must be populated in order to send to Azure. + + :param resource: Required. The standard JSON format of a resource + throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource + """ + + _validation = { + 'resource': {'required': True}, + } + + _attribute_map = { + 'resource': {'key': 'properties.resource', 'type': 'ThroughputResource'}, + } + + def __init__(self, **kwargs): + super(ThroughputUpdateParameters, self).__init__(**kwargs) + self.resource = kwargs.get('resource', None) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_update_parameters_py3.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_update_parameters_py3.py new file mode 100644 index 000000000000..9a7f4f1f3f01 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/throughput_update_parameters_py3.py @@ -0,0 +1,35 @@ +# 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 ThroughputUpdateParameters(Model): + """Parameters to update Cosmos DB resource throughput. + + All required parameters must be populated in order to send to Azure. + + :param resource: Required. The standard JSON format of a resource + throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource + """ + + _validation = { + 'resource': {'required': True}, + } + + _attribute_map = { + 'resource': {'key': 'properties.resource', 'type': 'ThroughputResource'}, + } + + def __init__(self, *, resource, **kwargs) -> None: + super(ThroughputUpdateParameters, self).__init__(**kwargs) + self.resource = resource diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/database_accounts_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/database_accounts_operations.py index b00dfdb99a2d..6c2b1f58d263 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/database_accounts_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/database_accounts_operations.py @@ -1491,7 +1491,7 @@ def internal_paging(next_link=None, raw=False): def get_sql_database( self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): - """Gets the SQL databases under an existing Azure Cosmos DB database + """Gets the SQL database under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: Name of an Azure resource group. @@ -1748,6 +1748,178 @@ def get_long_running_output(response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) delete_sql_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}'} + def get_sql_database_throughput( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): + """Gets the RUs per second of the SQL database under an existing Azure + Cosmos DB database account with the provided name. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_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`. + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_sql_database_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_sql_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/settings/throughput'} + + + def _update_sql_database_throughput_initial( + self, resource_group_name, account_name, database_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) + + # Construct URL + url = self.update_sql_database_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_throughput_parameters, 'ThroughputUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update_sql_database_throughput( + self, resource_group_name, account_name, database_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update RUs per second of an Azure Cosmos DB SQL database. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] + :raises: :class:`CloudError` + """ + raw_result = self._update_sql_database_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + resource=resource, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + update_sql_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/settings/throughput'} + def list_sql_containers( self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): """Lists the SQL container under an existing Azure Cosmos DB database @@ -2092,81 +2264,10 @@ def get_long_running_output(response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) delete_sql_container.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}'} - def list_mongo_db_databases( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Lists the MongoDB databases under an existing Azure Cosmos DB database - account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: Cosmos DB 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`. - :return: An iterator like instance of MongoDBDatabase - :rtype: - ~azure.mgmt.cosmosdb.models.MongoDBDatabasePaged[~azure.mgmt.cosmosdb.models.MongoDBDatabase] - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = self.list_mongo_db_databases.metadata['url'] - 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=r'^[-\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.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, stream=False, **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.MongoDBDatabasePaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.MongoDBDatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - list_mongo_db_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases'} - - def get_mongo_db_database( - self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): - """Gets the MongoDB databases under an existing Azure Cosmos DB database - account with the provided name. + def get_sql_container_throughput( + self, resource_group_name, account_name, database_name, container_name, custom_headers=None, raw=False, **operation_config): + """Gets the RUs per second of the SQL container under an existing Azure + Cosmos DB database account. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -2174,23 +2275,26 @@ def get_mongo_db_database( :type account_name: str :param database_name: Cosmos DB database name. :type database_name: str + :param container_name: Cosmos DB container name. + :type container_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`. - :return: MongoDBDatabase or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.cosmosdb.models.MongoDBDatabase or + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ # Construct URL - url = self.get_mongo_db_database.metadata['url'] + url = self.get_sql_container_throughput.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'databaseName': self._serialize.url("database_name", database_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'containerName': self._serialize.url("container_name", container_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -2220,27 +2324,28 @@ def get_mongo_db_database( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoDBDatabase', response) + deserialized = self._deserialize('Throughput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - get_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}'} + get_sql_container_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/settings/throughput'} - def _create_update_mongo_db_database_initial( - self, resource_group_name, account_name, database_name, resource, options, custom_headers=None, raw=False, **operation_config): - create_update_mongo_db_database_parameters = models.MongoDBDatabaseCreateUpdateParameters(resource=resource, options=options) + def _update_sql_container_throughput_initial( + self, resource_group_name, account_name, database_name, container_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) # Construct URL - url = self.create_update_mongo_db_database.metadata['url'] + url = self.update_sql_container_throughput.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'databaseName': self._serialize.url("database_name", database_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'containerName': self._serialize.url("container_name", container_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -2260,7 +2365,7 @@ def _create_update_mongo_db_database_initial( 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_mongo_db_database_parameters, 'MongoDBDatabaseCreateUpdateParameters') + body_content = self._serialize.body(update_throughput_parameters, 'ThroughputUpdateParameters') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -2274,7 +2379,7 @@ def _create_update_mongo_db_database_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoDBDatabase', response) + deserialized = self._deserialize('Throughput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -2282,9 +2387,9 @@ def _create_update_mongo_db_database_initial( return deserialized - def create_update_mongo_db_database( - self, resource_group_name, account_name, database_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): - """Create or updates Azure Cosmos DB MongoDB database. + def update_sql_container_throughput( + self, resource_group_name, account_name, database_name, container_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update RUs per second of an Azure Cosmos DB SQL container. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -2292,37 +2397,36 @@ def create_update_mongo_db_database( :type account_name: str :param database_name: Cosmos DB database name. :type database_name: str - :param resource: The standard JSON format of a MongoDB database - :type resource: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseResource - :param options: A key-value pair of options to be applied for the - request. This corresponds to the headers sent with the request. - :type options: dict[str, str] + :param container_name: Cosmos DB container name. + :type container_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns MongoDBDatabase or - ClientRawResponse if raw==True + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.MongoDBDatabase] + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.MongoDBDatabase]] + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] :raises: :class:`CloudError` """ - raw_result = self._create_update_mongo_db_database_initial( + raw_result = self._update_sql_container_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, resource=resource, - options=options, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): - deserialized = self._deserialize('MongoDBDatabase', response) + deserialized = self._deserialize('Throughput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -2337,122 +2441,36 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_update_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}'} - - - def _delete_mongo_db_database_initial( - self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): - # Construct URL - url = self.delete_mongo_db_database.metadata['url'] - 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=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'databaseName': self._serialize.url("database_name", database_name, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - 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.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - 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 - - def delete_mongo_db_database( - self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes an existing Azure Cosmos DB MongoDB database. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. - :type account_name: str - :param database_name: Cosmos DB database name. - :type database_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` - """ - raw_result = self._delete_mongo_db_database_initial( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - custom_headers=custom_headers, - raw=True, - **operation_config - ) - - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}'} + update_sql_container_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/settings/throughput'} - def list_mongo_db_collections( - self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): - """Lists the MongoDB collection under an existing Azure Cosmos DB database + def list_mongo_db_databases( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Lists the MongoDB databases under an existing Azure Cosmos DB database account. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str - :param database_name: Cosmos DB database name. - :type database_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`. - :return: An iterator like instance of MongoDBCollection + :return: An iterator like instance of MongoDBDatabase :rtype: - ~azure.mgmt.cosmosdb.models.MongoDBCollectionPaged[~azure.mgmt.cosmosdb.models.MongoDBCollection] + ~azure.mgmt.cosmosdb.models.MongoDBDatabasePaged[~azure.mgmt.cosmosdb.models.MongoDBDatabase] :raises: :class:`CloudError` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL - url = self.list_mongo_db_collections.metadata['url'] + url = self.list_mongo_db_databases.metadata['url'] 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=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'databaseName': self._serialize.url("database_name", database_name, 'str') + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) } url = self._client.format_url(url, **path_format_arguments) @@ -2486,20 +2504,20 @@ def internal_paging(next_link=None, raw=False): return response # Deserialize response - deserialized = models.MongoDBCollectionPaged(internal_paging, self._deserialize.dependencies) + deserialized = models.MongoDBDatabasePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} - client_raw_response = models.MongoDBCollectionPaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = models.MongoDBDatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized - list_mongo_db_collections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections'} + list_mongo_db_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases'} - def get_mongo_db_collection( - self, resource_group_name, account_name, database_name, collection_name, custom_headers=None, raw=False, **operation_config): - """Gets the MongoDB collection under an existing Azure Cosmos DB database - account. + def get_mongo_db_database( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): + """Gets the MongoDB databases under an existing Azure Cosmos DB database + account with the provided name. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -2507,26 +2525,23 @@ def get_mongo_db_collection( :type account_name: str :param database_name: Cosmos DB database name. :type database_name: str - :param collection_name: Cosmos DB collection name. - :type collection_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`. - :return: MongoDBCollection or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.cosmosdb.models.MongoDBCollection or + :return: MongoDBDatabase or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.MongoDBDatabase or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ # Construct URL - url = self.get_mongo_db_collection.metadata['url'] + url = self.get_mongo_db_database.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -2556,28 +2571,27 @@ def get_mongo_db_collection( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoDBCollection', response) + deserialized = self._deserialize('MongoDBDatabase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - get_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}'} + get_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}'} - def _create_update_mongo_db_collection_initial( - self, resource_group_name, account_name, database_name, collection_name, resource, options, custom_headers=None, raw=False, **operation_config): - create_update_mongo_db_collection_parameters = models.MongoDBCollectionCreateUpdateParameters(resource=resource, options=options) + def _create_update_mongo_db_database_initial( + self, resource_group_name, account_name, database_name, resource, options, custom_headers=None, raw=False, **operation_config): + create_update_mongo_db_database_parameters = models.MongoDBDatabaseCreateUpdateParameters(resource=resource, options=options) # Construct URL - url = self.create_update_mongo_db_collection.metadata['url'] + url = self.create_update_mongo_db_database.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -2597,7 +2611,7 @@ def _create_update_mongo_db_collection_initial( 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_mongo_db_collection_parameters, 'MongoDBCollectionCreateUpdateParameters') + body_content = self._serialize.body(create_update_mongo_db_database_parameters, 'MongoDBDatabaseCreateUpdateParameters') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -2611,7 +2625,7 @@ def _create_update_mongo_db_collection_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoDBCollection', response) + deserialized = self._deserialize('MongoDBDatabase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -2619,9 +2633,9 @@ def _create_update_mongo_db_collection_initial( return deserialized - def create_update_mongo_db_collection( - self, resource_group_name, account_name, database_name, collection_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): - """Create or update an Azure Cosmos DB MongoDB Collection. + def create_update_mongo_db_database( + self, resource_group_name, account_name, database_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): + """Create or updates Azure Cosmos DB MongoDB database. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -2629,10 +2643,8 @@ def create_update_mongo_db_collection( :type account_name: str :param database_name: Cosmos DB database name. :type database_name: str - :param collection_name: Cosmos DB collection name. - :type collection_name: str - :param resource: The standard JSON format of a MongoDB collection - :type resource: ~azure.mgmt.cosmosdb.models.MongoDBCollectionResource + :param resource: The standard JSON format of a MongoDB database + :type resource: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseResource :param options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. :type options: dict[str, str] @@ -2641,19 +2653,18 @@ def create_update_mongo_db_collection( direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns MongoDBCollection or - ClientRawResponse if raw==True + :return: An instance of LROPoller that returns MongoDBDatabase or + ClientRawResponse if raw==True :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.MongoDBCollection] + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.MongoDBDatabase] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.MongoDBCollection]] + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.MongoDBDatabase]] :raises: :class:`CloudError` """ - raw_result = self._create_update_mongo_db_collection_initial( + raw_result = self._create_update_mongo_db_database_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, resource=resource, options=options, custom_headers=custom_headers, @@ -2662,7 +2673,7 @@ def create_update_mongo_db_collection( ) def get_long_running_output(response): - deserialized = self._deserialize('MongoDBCollection', response) + deserialized = self._deserialize('MongoDBDatabase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -2677,19 +2688,18 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_update_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}'} + create_update_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}'} - def _delete_mongo_db_collection_initial( - self, resource_group_name, account_name, database_name, collection_name, custom_headers=None, raw=False, **operation_config): + def _delete_mongo_db_database_initial( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): # Construct URL - url = self.delete_mongo_db_collection.metadata['url'] + url = self.delete_mongo_db_database.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'collectionName': self._serialize.url("collection_name", collection_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -2719,9 +2729,9 @@ def _delete_mongo_db_collection_initial( client_raw_response = ClientRawResponse(None, response) return client_raw_response - def delete_mongo_db_collection( - self, resource_group_name, account_name, database_name, collection_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes an existing Azure Cosmos DB MongoDB Collection. + def delete_mongo_db_database( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes an existing Azure Cosmos DB MongoDB database. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -2729,8 +2739,6 @@ def delete_mongo_db_collection( :type account_name: str :param database_name: Cosmos DB database name. :type database_name: str - :param collection_name: Cosmos DB collection name. - :type collection_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response @@ -2742,11 +2750,10 @@ def delete_mongo_db_collection( ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError` """ - raw_result = self._delete_mongo_db_collection_initial( + raw_result = self._delete_mongo_db_database_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, custom_headers=custom_headers, raw=True, **operation_config @@ -2764,55 +2771,1757 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}'} + delete_mongo_db_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}'} - def list_tables( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Lists the Tables under an existing Azure Cosmos DB database account. + def get_mongo_db_database_throughput( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): + """Gets the RUs per second of the MongoDB database under an existing Azure + Cosmos DB database account with the provided name. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str + :param database_name: Cosmos DB database name. + :type database_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`. - :return: An iterator like instance of Table - :rtype: - ~azure.mgmt.cosmosdb.models.TablePaged[~azure.mgmt.cosmosdb.models.Table] + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or + ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = self.list_tables.metadata['url'] - 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=r'^[-\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 URL + url = self.get_mongo_db_database_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - else: - url = next_link - query_parameters = {} + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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 headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - 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, header_parameters) + response = self._client.send(request, stream=False, **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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_mongo_db_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/settings/throughput'} + + + def _update_mongo_db_database_throughput_initial( + self, resource_group_name, account_name, database_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) + + # Construct URL + url = self.update_mongo_db_database_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_throughput_parameters, 'ThroughputUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update_mongo_db_database_throughput( + self, resource_group_name, account_name, database_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update RUs per second of the an Azure Cosmos DB MongoDB database. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] + :raises: :class:`CloudError` + """ + raw_result = self._update_mongo_db_database_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + resource=resource, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + update_mongo_db_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/settings/throughput'} + + def list_mongo_db_collections( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): + """Lists the MongoDB collection under an existing Azure Cosmos DB database + account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_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`. + :return: An iterator like instance of MongoDBCollection + :rtype: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionPaged[~azure.mgmt.cosmosdb.models.MongoDBCollection] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_mongo_db_collections.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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.MongoDBCollectionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MongoDBCollectionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_mongo_db_collections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections'} + + def get_mongo_db_collection( + self, resource_group_name, account_name, database_name, collection_name, custom_headers=None, raw=False, **operation_config): + """Gets the MongoDB collection under an existing Azure Cosmos DB database + account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param collection_name: Cosmos DB collection name. + :type collection_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`. + :return: MongoDBCollection or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.MongoDBCollection or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_mongo_db_collection.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'collectionName': self._serialize.url("collection_name", collection_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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('MongoDBCollection', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}'} + + + def _create_update_mongo_db_collection_initial( + self, resource_group_name, account_name, database_name, collection_name, resource, options, custom_headers=None, raw=False, **operation_config): + create_update_mongo_db_collection_parameters = models.MongoDBCollectionCreateUpdateParameters(resource=resource, options=options) + + # Construct URL + url = self.create_update_mongo_db_collection.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'collectionName': self._serialize.url("collection_name", collection_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_mongo_db_collection_parameters, 'MongoDBCollectionCreateUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('MongoDBCollection', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_update_mongo_db_collection( + self, resource_group_name, account_name, database_name, collection_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): + """Create or update an Azure Cosmos DB MongoDB Collection. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param collection_name: Cosmos DB collection name. + :type collection_name: str + :param resource: The standard JSON format of a MongoDB collection + :type resource: ~azure.mgmt.cosmosdb.models.MongoDBCollectionResource + :param options: A key-value pair of options to be applied for the + request. This corresponds to the headers sent with the request. + :type options: dict[str, str] + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns MongoDBCollection or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.MongoDBCollection] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.MongoDBCollection]] + :raises: :class:`CloudError` + """ + raw_result = self._create_update_mongo_db_collection_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + resource=resource, + options=options, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('MongoDBCollection', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + create_update_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}'} + + + def _delete_mongo_db_collection_initial( + self, resource_group_name, account_name, database_name, collection_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete_mongo_db_collection.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'collectionName': self._serialize.url("collection_name", collection_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + 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.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + 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 + + def delete_mongo_db_collection( + self, resource_group_name, account_name, database_name, collection_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes an existing Azure Cosmos DB MongoDB Collection. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param collection_name: Cosmos DB collection name. + :type collection_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._delete_mongo_db_collection_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete_mongo_db_collection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}'} + + def get_mongo_db_collection_throughput( + self, resource_group_name, account_name, database_name, collection_name, custom_headers=None, raw=False, **operation_config): + """Gets the RUs per second of the MongoDB collection under an existing + Azure Cosmos DB database account with the provided name. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param collection_name: Cosmos DB collection name. + :type collection_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`. + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_mongo_db_collection_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'collectionName': self._serialize.url("collection_name", collection_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_mongo_db_collection_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}/settings/throughput'} + + + def _update_mongo_db_collection_throughput_initial( + self, resource_group_name, account_name, database_name, collection_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) + + # Construct URL + url = self.update_mongo_db_collection_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'collectionName': self._serialize.url("collection_name", collection_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_throughput_parameters, 'ThroughputUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update_mongo_db_collection_throughput( + self, resource_group_name, account_name, database_name, collection_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param collection_name: Cosmos DB collection name. + :type collection_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] + :raises: :class:`CloudError` + """ + raw_result = self._update_mongo_db_collection_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + resource=resource, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + update_mongo_db_collection_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}/settings/throughput'} + + def list_tables( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Lists the Tables under an existing Azure Cosmos DB database account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB 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`. + :return: An iterator like instance of Table + :rtype: + ~azure.mgmt.cosmosdb.models.TablePaged[~azure.mgmt.cosmosdb.models.Table] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_tables.metadata['url'] + 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=r'^[-\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.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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.TablePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.TablePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_tables.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables'} + + def get_table( + self, resource_group_name, account_name, table_name, custom_headers=None, raw=False, **operation_config): + """Gets the Tables under an existing Azure Cosmos DB database account with + the provided name. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param table_name: Cosmos DB table name. + :type table_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`. + :return: Table or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Table or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_table.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'tableName': self._serialize.url("table_name", table_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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('Table', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}'} + + + def _create_update_table_initial( + self, resource_group_name, account_name, table_name, resource, options, custom_headers=None, raw=False, **operation_config): + create_update_table_parameters = models.TableCreateUpdateParameters(resource=resource, options=options) + + # Construct URL + url = self.create_update_table.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'tableName': self._serialize.url("table_name", table_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_table_parameters, 'TableCreateUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('Table', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_update_table( + self, resource_group_name, account_name, table_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): + """Create or update an Azure Cosmos DB Table. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param table_name: Cosmos DB table name. + :type table_name: str + :param resource: The standard JSON format of a Table + :type resource: ~azure.mgmt.cosmosdb.models.TableResource + :param options: A key-value pair of options to be applied for the + request. This corresponds to the headers sent with the request. + :type options: dict[str, str] + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Table or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Table] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Table]] + :raises: :class:`CloudError` + """ + raw_result = self._create_update_table_initial( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + resource=resource, + options=options, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Table', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + create_update_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}'} + + + def _delete_table_initial( + self, resource_group_name, account_name, table_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete_table.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'tableName': self._serialize.url("table_name", table_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + 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.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + 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 + + def delete_table( + self, resource_group_name, account_name, table_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes an existing Azure Cosmos DB Table. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param table_name: Cosmos DB table name. + :type table_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._delete_table_initial( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}'} + + def get_table_throughput( + self, resource_group_name, account_name, table_name, custom_headers=None, raw=False, **operation_config): + """Gets the RUs per second of the Table under an existing Azure Cosmos DB + database account with the provided name. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param table_name: Cosmos DB table name. + :type table_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`. + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_table_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'tableName': self._serialize.url("table_name", table_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}/settings/throughput'} + + + def _update_table_throughput_initial( + self, resource_group_name, account_name, table_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) + + # Construct URL + url = self.update_table_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'tableName': self._serialize.url("table_name", table_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_throughput_parameters, 'ThroughputUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update_table_throughput( + self, resource_group_name, account_name, table_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update RUs per second of an Azure Cosmos DB Table. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param table_name: Cosmos DB table name. + :type table_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] + :raises: :class:`CloudError` + """ + raw_result = self._update_table_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + resource=resource, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + update_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}/settings/throughput'} + + def list_cassandra_keyspaces( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Lists the Cassandra keyspaces under an existing Azure Cosmos DB + database account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB 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`. + :return: An iterator like instance of CassandraKeyspace + :rtype: + ~azure.mgmt.cosmosdb.models.CassandraKeyspacePaged[~azure.mgmt.cosmosdb.models.CassandraKeyspace] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_cassandra_keyspaces.metadata['url'] + 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=r'^[-\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.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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.CassandraKeyspacePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.CassandraKeyspacePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_cassandra_keyspaces.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces'} + + def get_cassandra_keyspace( + self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, **operation_config): + """Gets the Cassandra keyspaces under an existing Azure Cosmos DB database + account with the provided name. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_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`. + :return: CassandraKeyspace or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.CassandraKeyspace or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_cassandra_keyspace.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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('CassandraKeyspace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}'} + + + def _create_update_cassandra_keyspace_initial( + self, resource_group_name, account_name, keyspace_name, resource, options, custom_headers=None, raw=False, **operation_config): + create_update_cassandra_keyspace_parameters = models.CassandraKeyspaceCreateUpdateParameters(resource=resource, options=options) + + # Construct URL + url = self.create_update_cassandra_keyspace.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_cassandra_keyspace_parameters, 'CassandraKeyspaceCreateUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('CassandraKeyspace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_update_cassandra_keyspace( + self, resource_group_name, account_name, keyspace_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): + """Create or update an Azure Cosmos DB Cassandra keyspace. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_name: str + :param resource: The standard JSON format of a Cassandra keyspace + :type resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceResource + :param options: A key-value pair of options to be applied for the + request. This corresponds to the headers sent with the request. + :type options: dict[str, str] + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns CassandraKeyspace or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspace] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.CassandraKeyspace]] + :raises: :class:`CloudError` + """ + raw_result = self._create_update_cassandra_keyspace_initial( + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + resource=resource, + options=options, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('CassandraKeyspace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + create_update_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}'} + + + def _delete_cassandra_keyspace_initial( + self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete_cassandra_keyspace.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + 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.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + 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 + + def delete_cassandra_keyspace( + self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes an existing Azure Cosmos DB Cassandra keyspace. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._delete_cassandra_keyspace_initial( + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}'} + + def get_cassandra_keyspace_throughput( + self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, **operation_config): + """Gets the RUs per second of the Cassandra Keyspace under an existing + Azure Cosmos DB database account with the provided name. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_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`. + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_cassandra_keyspace_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_cassandra_keyspace_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/settings/throughput'} + + + def _update_cassandra_keyspace_throughput_initial( + self, resource_group_name, account_name, keyspace_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) + + # Construct URL + url = self.update_cassandra_keyspace_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_throughput_parameters, 'ThroughputUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update_cassandra_keyspace_throughput( + self, resource_group_name, account_name, keyspace_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] + :raises: :class:`CloudError` + """ + raw_result = self._update_cassandra_keyspace_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + resource=resource, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + update_cassandra_keyspace_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/settings/throughput'} + + def list_cassandra_tables( + self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, **operation_config): + """Lists the Cassandra table under an existing Azure Cosmos DB database + account. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_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`. + :return: An iterator like instance of CassandraTable + :rtype: + ~azure.mgmt.cosmosdb.models.CassandraTablePaged[~azure.mgmt.cosmosdb.models.CassandraTable] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_cassandra_tables.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) @@ -2826,25 +4535,27 @@ def internal_paging(next_link=None, raw=False): return response # Deserialize response - deserialized = models.TablePaged(internal_paging, self._deserialize.dependencies) + deserialized = models.CassandraTablePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} - client_raw_response = models.TablePaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = models.CassandraTablePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized - list_tables.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables'} + list_cassandra_tables.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables'} - def get_table( - self, resource_group_name, account_name, table_name, custom_headers=None, raw=False, **operation_config): - """Gets the Tables under an existing Azure Cosmos DB database account with - the provided name. + def get_cassandra_table( + self, resource_group_name, account_name, keyspace_name, table_name, custom_headers=None, raw=False, **operation_config): + """Gets the Cassandra table under an existing Azure Cosmos DB database + account. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_name: str :param table_name: Cosmos DB table name. :type table_name: str :param dict custom_headers: headers that will be added to the request @@ -2852,17 +4563,18 @@ def get_table( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: Table or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.cosmosdb.models.Table or + :return: CassandraTable or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.CassandraTable or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ # Construct URL - url = self.get_table.metadata['url'] + url = self.get_cassandra_table.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), 'tableName': self._serialize.url("table_name", table_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -2893,26 +4605,27 @@ def get_table( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Table', response) + deserialized = self._deserialize('CassandraTable', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - get_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}'} - + get_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}'} - def _create_update_table_initial( - self, resource_group_name, account_name, table_name, resource, options, custom_headers=None, raw=False, **operation_config): - create_update_table_parameters = models.TableCreateUpdateParameters(resource=resource, options=options) + + def _create_update_cassandra_table_initial( + self, resource_group_name, account_name, keyspace_name, table_name, resource, options, custom_headers=None, raw=False, **operation_config): + create_update_cassandra_table_parameters = models.CassandraTableCreateUpdateParameters(resource=resource, options=options) # Construct URL - url = self.create_update_table.metadata['url'] + url = self.create_update_cassandra_table.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), 'tableName': self._serialize.url("table_name", table_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -2933,7 +4646,7 @@ def _create_update_table_initial( 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_table_parameters, 'TableCreateUpdateParameters') + body_content = self._serialize.body(create_update_cassandra_table_parameters, 'CassandraTableCreateUpdateParameters') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -2947,7 +4660,7 @@ def _create_update_table_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Table', response) + deserialized = self._deserialize('CassandraTable', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -2955,18 +4668,20 @@ def _create_update_table_initial( return deserialized - def create_update_table( - self, resource_group_name, account_name, table_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): - """Create or update an Azure Cosmos DB Table. + def create_update_cassandra_table( + self, resource_group_name, account_name, keyspace_name, table_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): + """Create or update an Azure Cosmos DB Cassandra Table. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_name: str :param table_name: Cosmos DB table name. :type table_name: str - :param resource: The standard JSON format of a Table - :type resource: ~azure.mgmt.cosmosdb.models.TableResource + :param resource: The standard JSON format of a Cassandra table + :type resource: ~azure.mgmt.cosmosdb.models.CassandraTableResource :param options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. :type options: dict[str, str] @@ -2975,17 +4690,18 @@ def create_update_table( direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns Table or - ClientRawResponse
if raw==True + :return: An instance of LROPoller that returns CassandraTable or + ClientRawResponse if raw==True :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Table] + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.CassandraTable] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Table]] + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.CassandraTable]] :raises: :class:`CloudError` """ - raw_result = self._create_update_table_initial( + raw_result = self._create_update_cassandra_table_initial( resource_group_name=resource_group_name, account_name=account_name, + keyspace_name=keyspace_name, table_name=table_name, resource=resource, options=options, @@ -2995,7 +4711,7 @@ def create_update_table( ) def get_long_running_output(response): - deserialized = self._deserialize('Table', response) + deserialized = self._deserialize('CassandraTable', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -3010,17 +4726,18 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_update_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}'} + create_update_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}'} - def _delete_table_initial( - self, resource_group_name, account_name, table_name, custom_headers=None, raw=False, **operation_config): + def _delete_cassandra_table_initial( + self, resource_group_name, account_name, keyspace_name, table_name, custom_headers=None, raw=False, **operation_config): # Construct URL - url = self.delete_table.metadata['url'] + url = self.delete_cassandra_table.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), 'tableName': self._serialize.url("table_name", table_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -3051,14 +4768,16 @@ def _delete_table_initial( client_raw_response = ClientRawResponse(None, response) return client_raw_response - def delete_table( - self, resource_group_name, account_name, table_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes an existing Azure Cosmos DB Table. + def delete_cassandra_table( + self, resource_group_name, account_name, keyspace_name, table_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes an existing Azure Cosmos DB Cassandra table. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. + :type keyspace_name: str :param table_name: Cosmos DB table name. :type table_name: str :param dict custom_headers: headers that will be added to the request @@ -3072,9 +4791,10 @@ def delete_table( ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError` """ - raw_result = self._delete_table_initial( + raw_result = self._delete_cassandra_table_initial( resource_group_name=resource_group_name, account_name=account_name, + keyspace_name=keyspace_name, table_name=table_name, custom_headers=custom_headers, raw=True, @@ -3093,83 +4813,12 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}'} - - def list_cassandra_keyspaces( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Lists the Cassandra keyspaces under an existing Azure Cosmos DB - database account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: Cosmos DB 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`. - :return: An iterator like instance of CassandraKeyspace - :rtype: - ~azure.mgmt.cosmosdb.models.CassandraKeyspacePaged[~azure.mgmt.cosmosdb.models.CassandraKeyspace] - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = self.list_cassandra_keyspaces.metadata['url'] - 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=r'^[-\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.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, stream=False, **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.CassandraKeyspacePaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.CassandraKeyspacePaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - list_cassandra_keyspaces.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces'} + delete_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}'} - def get_cassandra_keyspace( - self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, **operation_config): - """Gets the Cassandra keyspaces under an existing Azure Cosmos DB database - account with the provided name. + def get_cassandra_table_throughput( + self, resource_group_name, account_name, keyspace_name, table_name, custom_headers=None, raw=False, **operation_config): + """Gets the RUs per second of the Cassandra table under an existing Azure + Cosmos DB database account with the provided name. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -3177,23 +4826,26 @@ def get_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. :type keyspace_name: str + :param table_name: Cosmos DB table name. + :type table_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`. - :return: CassandraKeyspace or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.cosmosdb.models.CassandraKeyspace or + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ # Construct URL - url = self.get_cassandra_keyspace.metadata['url'] + url = self.get_cassandra_table_throughput.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), + 'tableName': self._serialize.url("table_name", table_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -3223,27 +4875,28 @@ def get_cassandra_keyspace( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraKeyspace', response) + deserialized = self._deserialize('Throughput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - get_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}'} + get_cassandra_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}/settings/throughput'} - def _create_update_cassandra_keyspace_initial( - self, resource_group_name, account_name, keyspace_name, resource, options, custom_headers=None, raw=False, **operation_config): - create_update_cassandra_keyspace_parameters = models.CassandraKeyspaceCreateUpdateParameters(resource=resource, options=options) + def _update_cassandra_table_throughput_initial( + self, resource_group_name, account_name, keyspace_name, table_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) # Construct URL - url = self.create_update_cassandra_keyspace.metadata['url'] + url = self.update_cassandra_table_throughput.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), + 'tableName': self._serialize.url("table_name", table_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -3263,7 +4916,7 @@ def _create_update_cassandra_keyspace_initial( 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_cassandra_keyspace_parameters, 'CassandraKeyspaceCreateUpdateParameters') + body_content = self._serialize.body(update_throughput_parameters, 'ThroughputUpdateParameters') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -3277,7 +4930,7 @@ def _create_update_cassandra_keyspace_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraKeyspace', response) + deserialized = self._deserialize('Throughput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -3285,9 +4938,9 @@ def _create_update_cassandra_keyspace_initial( return deserialized - def create_update_cassandra_keyspace( - self, resource_group_name, account_name, keyspace_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): - """Create or update an Azure Cosmos DB Cassandra keyspace. + def update_cassandra_table_throughput( + self, resource_group_name, account_name, keyspace_name, table_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -3295,127 +4948,43 @@ def create_update_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. :type keyspace_name: str - :param resource: The standard JSON format of a Cassandra keyspace - :type resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceResource - :param options: A key-value pair of options to be applied for the - request. This corresponds to the headers sent with the request. - :type options: dict[str, str] + :param table_name: Cosmos DB table name. + :type table_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns CassandraKeyspace or - ClientRawResponse if raw==True + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspace] + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.CassandraKeyspace]] + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] :raises: :class:`CloudError` """ - raw_result = self._create_update_cassandra_keyspace_initial( + raw_result = self._update_cassandra_table_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, resource=resource, - options=options, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): - deserialized = self._deserialize('CassandraKeyspace', response) + deserialized = self._deserialize('Throughput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response - return deserialized - - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_update_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}'} - - - def _delete_cassandra_keyspace_initial( - self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, **operation_config): - # Construct URL - url = self.delete_cassandra_keyspace.metadata['url'] - 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=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - 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.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - 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 - - def delete_cassandra_keyspace( - self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes an existing Azure Cosmos DB Cassandra keyspace. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. - :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. - :type keyspace_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` - """ - raw_result = self._delete_cassandra_keyspace_initial( - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_name, - custom_headers=custom_headers, - raw=True, - **operation_config - ) - - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - + return deserialized + lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) @@ -3423,39 +4992,36 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_cassandra_keyspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}'} + update_cassandra_table_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}/settings/throughput'} - def list_cassandra_tables( - self, resource_group_name, account_name, keyspace_name, custom_headers=None, raw=False, **operation_config): - """Lists the Cassandra table under an existing Azure Cosmos DB database + def list_gremlin_databases( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Lists the Gremlin databases under an existing Azure Cosmos DB database account. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. - :type keyspace_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`. - :return: An iterator like instance of CassandraTable + :return: An iterator like instance of GremlinDatabase :rtype: - ~azure.mgmt.cosmosdb.models.CassandraTablePaged[~azure.mgmt.cosmosdb.models.CassandraTable] + ~azure.mgmt.cosmosdb.models.GremlinDatabasePaged[~azure.mgmt.cosmosdb.models.GremlinDatabase] :raises: :class:`CloudError` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL - url = self.list_cassandra_tables.metadata['url'] + url = self.list_gremlin_databases.metadata['url'] 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=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str') + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3) } url = self._client.format_url(url, **path_format_arguments) @@ -3489,47 +5055,44 @@ def internal_paging(next_link=None, raw=False): return response # Deserialize response - deserialized = models.CassandraTablePaged(internal_paging, self._deserialize.dependencies) + deserialized = models.GremlinDatabasePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} - client_raw_response = models.CassandraTablePaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = models.GremlinDatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized - list_cassandra_tables.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables'} + list_gremlin_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases'} - def get_cassandra_table( - self, resource_group_name, account_name, keyspace_name, table_name, custom_headers=None, raw=False, **operation_config): - """Gets the Cassandra table under an existing Azure Cosmos DB database - account. + def get_gremlin_database( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): + """Gets the Gremlin databases under an existing Azure Cosmos DB database + account with the provided name. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. - :type keyspace_name: str - :param table_name: Cosmos DB table name. - :type table_name: str + :param database_name: Cosmos DB database name. + :type database_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`. - :return: CassandraTable or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.cosmosdb.models.CassandraTable or + :return: GremlinDatabase or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.GremlinDatabase or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ # Construct URL - url = self.get_cassandra_table.metadata['url'] + url = self.get_gremlin_database.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -3559,28 +5122,27 @@ def get_cassandra_table( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraTable', response) + deserialized = self._deserialize('GremlinDatabase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - get_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}'} + get_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}'} - def _create_update_cassandra_table_initial( - self, resource_group_name, account_name, keyspace_name, table_name, resource, options, custom_headers=None, raw=False, **operation_config): - create_update_cassandra_table_parameters = models.CassandraTableCreateUpdateParameters(resource=resource, options=options) + def _create_update_gremlin_database_initial( + self, resource_group_name, account_name, database_name, resource, options, custom_headers=None, raw=False, **operation_config): + create_update_gremlin_database_parameters = models.GremlinDatabaseCreateUpdateParameters(resource=resource, options=options) # Construct URL - url = self.create_update_cassandra_table.metadata['url'] + url = self.create_update_gremlin_database.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -3600,7 +5162,7 @@ def _create_update_cassandra_table_initial( 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_cassandra_table_parameters, 'CassandraTableCreateUpdateParameters') + body_content = self._serialize.body(create_update_gremlin_database_parameters, 'GremlinDatabaseCreateUpdateParameters') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -3614,7 +5176,7 @@ def _create_update_cassandra_table_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraTable', response) + deserialized = self._deserialize('GremlinDatabase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -3622,20 +5184,18 @@ def _create_update_cassandra_table_initial( return deserialized - def create_update_cassandra_table( - self, resource_group_name, account_name, keyspace_name, table_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): - """Create or update an Azure Cosmos DB Cassandra Table. + def create_update_gremlin_database( + self, resource_group_name, account_name, database_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): + """Create or update an Azure Cosmos DB Gremlin database. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. - :type keyspace_name: str - :param table_name: Cosmos DB table name. - :type table_name: str - :param resource: The standard JSON format of a Cassandra table - :type resource: ~azure.mgmt.cosmosdb.models.CassandraTableResource + :param database_name: Cosmos DB database name. + :type database_name: str + :param resource: The standard JSON format of a Gremlin database + :type resource: ~azure.mgmt.cosmosdb.models.GremlinDatabaseResource :param options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. :type options: dict[str, str] @@ -3644,19 +5204,18 @@ def create_update_cassandra_table( direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns CassandraTable or - ClientRawResponse if raw==True + :return: An instance of LROPoller that returns GremlinDatabase or + ClientRawResponse if raw==True :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.CassandraTable] + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.GremlinDatabase] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.CassandraTable]] + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.GremlinDatabase]] :raises: :class:`CloudError` """ - raw_result = self._create_update_cassandra_table_initial( + raw_result = self._create_update_gremlin_database_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - table_name=table_name, + database_name=database_name, resource=resource, options=options, custom_headers=custom_headers, @@ -3665,7 +5224,7 @@ def create_update_cassandra_table( ) def get_long_running_output(response): - deserialized = self._deserialize('CassandraTable', response) + deserialized = self._deserialize('GremlinDatabase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -3680,19 +5239,18 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_update_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}'} + create_update_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}'} - def _delete_cassandra_table_initial( - self, resource_group_name, account_name, keyspace_name, table_name, custom_headers=None, raw=False, **operation_config): + def _delete_gremlin_database_initial( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): # Construct URL - url = self.delete_cassandra_table.metadata['url'] + url = self.delete_gremlin_database.metadata['url'] 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=r'^[-\w\._\(\)]+$'), 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'keyspaceName': self._serialize.url("keyspace_name", keyspace_name, 'str'), - 'tableName': self._serialize.url("table_name", table_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -3722,18 +5280,16 @@ def _delete_cassandra_table_initial( client_raw_response = ClientRawResponse(None, response) return client_raw_response - def delete_cassandra_table( - self, resource_group_name, account_name, keyspace_name, table_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes an existing Azure Cosmos DB Cassandra table. + def delete_gremlin_database( + self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes an existing Azure Cosmos DB Gremlin database. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param account_name: Cosmos DB database account name. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. - :type keyspace_name: str - :param table_name: Cosmos DB table name. - :type table_name: str + :param database_name: Cosmos DB database name. + :type database_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response @@ -3745,11 +5301,10 @@ def delete_cassandra_table( ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError` """ - raw_result = self._delete_cassandra_table_initial( + raw_result = self._delete_gremlin_database_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - table_name=table_name, + database_name=database_name, custom_headers=custom_headers, raw=True, **operation_config @@ -3767,83 +5322,12 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_cassandra_table.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}'} - - def list_gremlin_databases( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Lists the Gremlin databases under an existing Azure Cosmos DB database - account. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: Cosmos DB 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`. - :return: An iterator like instance of GremlinDatabase - :rtype: - ~azure.mgmt.cosmosdb.models.GremlinDatabasePaged[~azure.mgmt.cosmosdb.models.GremlinDatabase] - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = self.list_gremlin_databases.metadata['url'] - 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=r'^[-\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.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, stream=False, **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.GremlinDatabasePaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.GremlinDatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - list_gremlin_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases'} + delete_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}'} - def get_gremlin_database( + def get_gremlin_database_throughput( self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): - """Gets the Gremlin databases under an existing Azure Cosmos DB database - account with the provided name. + """Gets the RUs per second of the Gremlin database under an existing Azure + Cosmos DB database account with the provided name. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -3856,63 +5340,13 @@ def get_gremlin_database( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: GremlinDatabase or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.cosmosdb.models.GremlinDatabase or + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_gremlin_database.metadata['url'] - 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=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), - 'databaseName': self._serialize.url("database_name", database_name, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, stream=False, **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('GremlinDatabase', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}'} - - - def _create_update_gremlin_database_initial( - self, resource_group_name, account_name, database_name, resource, options, custom_headers=None, raw=False, **operation_config): - create_update_gremlin_database_parameters = models.GremlinDatabaseCreateUpdateParameters(resource=resource, options=options) - + """ # Construct URL - url = self.create_update_gremlin_database.metadata['url'] + url = self.get_gremlin_database_throughput.metadata['url'] 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=r'^[-\w\._\(\)]+$'), @@ -3928,7 +5362,6 @@ def _create_update_gremlin_database_initial( # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' - 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: @@ -3936,14 +5369,11 @@ def _create_update_gremlin_database_initial( 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_gremlin_database_parameters, 'GremlinDatabaseCreateUpdateParameters') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) + request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [200, 202]: + if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp @@ -3951,76 +5381,22 @@ def _create_update_gremlin_database_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GremlinDatabase', response) + deserialized = self._deserialize('Throughput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized + get_gremlin_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/settings/throughput'} - def create_update_gremlin_database( - self, resource_group_name, account_name, database_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): - """Create or update an Azure Cosmos DB Gremlin database. - - :param resource_group_name: Name of an Azure resource group. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. - :type account_name: str - :param database_name: Cosmos DB database name. - :type database_name: str - :param resource: The standard JSON format of a Gremlin database - :type resource: ~azure.mgmt.cosmosdb.models.GremlinDatabaseResource - :param options: A key-value pair of options to be applied for the - request. This corresponds to the headers sent with the request. - :type options: dict[str, str] - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns GremlinDatabase or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.GremlinDatabase] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.GremlinDatabase]] - :raises: :class:`CloudError` - """ - raw_result = self._create_update_gremlin_database_initial( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - resource=resource, - options=options, - custom_headers=custom_headers, - raw=True, - **operation_config - ) - - def get_long_running_output(response): - deserialized = self._deserialize('GremlinDatabase', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_update_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}'} + def _update_gremlin_database_throughput_initial( + self, resource_group_name, account_name, database_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) - def _delete_gremlin_database_initial( - self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): # Construct URL - url = self.delete_gremlin_database.metadata['url'] + url = self.update_gremlin_database_throughput.metadata['url'] 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=r'^[-\w\._\(\)]+$'), @@ -4035,6 +5411,8 @@ def _delete_gremlin_database_initial( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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: @@ -4042,22 +5420,32 @@ def _delete_gremlin_database_initial( 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_throughput_parameters, 'ThroughputUpdateParameters') + # Construct and send request - request = self._client.delete(url, query_parameters, header_parameters) + request = self._client.put(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: 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('Throughput', response) + if raw: - client_raw_response = ClientRawResponse(None, response) + client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response - def delete_gremlin_database( - self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes an existing Azure Cosmos DB Gremlin database. + return deserialized + + def update_gremlin_database_throughput( + self, resource_group_name, account_name, database_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str @@ -4065,31 +5453,40 @@ def delete_gremlin_database( :type account_name: str :param database_name: Cosmos DB database name. :type database_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] :raises: :class:`CloudError` """ - raw_result = self._delete_gremlin_database_initial( + raw_result = self._update_gremlin_database_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + resource=resource, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): + deserialized = self._deserialize('Throughput', response) + if raw: - client_raw_response = ClientRawResponse(None, response) + client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response + return deserialized + lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) @@ -4097,7 +5494,7 @@ def get_long_running_output(response): elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_gremlin_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}'} + update_gremlin_database_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/settings/throughput'} def list_gremlin_graphs( self, resource_group_name, account_name, database_name, custom_headers=None, raw=False, **operation_config): @@ -4442,3 +5839,182 @@ def get_long_running_output(response): else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) delete_gremlin_graph.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/graphs/{graphName}'} + + def get_gremlin_graph_throughput( + self, resource_group_name, account_name, database_name, graph_name, custom_headers=None, raw=False, **operation_config): + """Gets the Gremlin graph throughput under an existing Azure Cosmos DB + database account with the provided name. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param graph_name: Cosmos DB graph name. + :type graph_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`. + :return: Throughput or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.Throughput or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_gremlin_graph_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'graphName': self._serialize.url("graph_name", graph_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_gremlin_graph_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/graphs/{graphName}/settings/throughput'} + + + def _update_gremlin_graph_throughput_initial( + self, resource_group_name, account_name, database_name, graph_name, resource, custom_headers=None, raw=False, **operation_config): + update_throughput_parameters = models.ThroughputUpdateParameters(resource=resource) + + # Construct URL + url = self.update_gremlin_graph_throughput.metadata['url'] + 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=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=50, min_length=3), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'graphName': self._serialize.url("graph_name", graph_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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_throughput_parameters, 'ThroughputUpdateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update_gremlin_graph_throughput( + self, resource_group_name, account_name, database_name, graph_name, resource, custom_headers=None, raw=False, polling=True, **operation_config): + """Update RUs per second of an Azure Cosmos DB Gremlin graph. + + :param resource_group_name: Name of an Azure resource group. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. + :type account_name: str + :param database_name: Cosmos DB database name. + :type database_name: str + :param graph_name: Cosmos DB graph name. + :type graph_name: str + :param resource: The standard JSON format of a resource throughput + :type resource: ~azure.mgmt.cosmosdb.models.ThroughputResource + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Throughput or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.Throughput] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.Throughput]] + :raises: :class:`CloudError` + """ + raw_result = self._update_gremlin_graph_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + resource=resource, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Throughput', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + update_gremlin_graph_throughput.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/graphs/{graphName}/settings/throughput'} diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/version.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/version.py index 2f337cfc0adf..981739e4ff95 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/version.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.6.1" +VERSION = "0.7.0"