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 79e3a4f08285..69f01ca56909 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 @@ -26,6 +26,7 @@ from .unique_key_policy_py3 import UniqueKeyPolicy from .conflict_resolution_policy_py3 import ConflictResolutionPolicy from .sql_container_py3 import SqlContainer + from .sql_stored_procedure_py3 import SqlStoredProcedure from .mongo_db_database_py3 import MongoDBDatabase from .mongo_db_collection_py3 import MongoDBCollection from .table_py3 import Table @@ -52,6 +53,8 @@ from .sql_database_create_update_parameters_py3 import SqlDatabaseCreateUpdateParameters from .sql_container_resource_py3 import SqlContainerResource from .sql_container_create_update_parameters_py3 import SqlContainerCreateUpdateParameters + from .sql_stored_procedure_resource_py3 import SqlStoredProcedureResource + from .sql_stored_procedure_create_update_parameters_py3 import SqlStoredProcedureCreateUpdateParameters from .mongo_db_database_resource_py3 import MongoDBDatabaseResource from .mongo_db_database_create_update_parameters_py3 import MongoDBDatabaseCreateUpdateParameters from .mongo_index_keys_py3 import MongoIndexKeys @@ -102,6 +105,7 @@ from .unique_key_policy import UniqueKeyPolicy from .conflict_resolution_policy import ConflictResolutionPolicy from .sql_container import SqlContainer + from .sql_stored_procedure import SqlStoredProcedure from .mongo_db_database import MongoDBDatabase from .mongo_db_collection import MongoDBCollection from .table import Table @@ -128,6 +132,8 @@ from .sql_database_create_update_parameters import SqlDatabaseCreateUpdateParameters from .sql_container_resource import SqlContainerResource from .sql_container_create_update_parameters import SqlContainerCreateUpdateParameters + from .sql_stored_procedure_resource import SqlStoredProcedureResource + from .sql_stored_procedure_create_update_parameters import SqlStoredProcedureCreateUpdateParameters from .mongo_db_database_resource import MongoDBDatabaseResource from .mongo_db_database_create_update_parameters import MongoDBDatabaseCreateUpdateParameters from .mongo_index_keys import MongoIndexKeys @@ -167,6 +173,7 @@ from .metric_definition_paged import MetricDefinitionPaged from .sql_database_paged import SqlDatabasePaged from .sql_container_paged import SqlContainerPaged +from .sql_stored_procedure_paged import SqlStoredProcedurePaged from .mongo_db_database_paged import MongoDBDatabasePaged from .mongo_db_collection_paged import MongoDBCollectionPaged from .table_paged import TablePaged @@ -210,6 +217,7 @@ 'UniqueKeyPolicy', 'ConflictResolutionPolicy', 'SqlContainer', + 'SqlStoredProcedure', 'MongoDBDatabase', 'MongoDBCollection', 'Table', @@ -236,6 +244,8 @@ 'SqlDatabaseCreateUpdateParameters', 'SqlContainerResource', 'SqlContainerCreateUpdateParameters', + 'SqlStoredProcedureResource', + 'SqlStoredProcedureCreateUpdateParameters', 'MongoDBDatabaseResource', 'MongoDBDatabaseCreateUpdateParameters', 'MongoIndexKeys', @@ -275,6 +285,7 @@ 'MetricDefinitionPaged', 'SqlDatabasePaged', 'SqlContainerPaged', + 'SqlStoredProcedurePaged', 'MongoDBDatabasePaged', 'MongoDBCollectionPaged', 'TablePaged', diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure.py new file mode 100644 index 000000000000..a3c62175ed05 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure.py @@ -0,0 +1,71 @@ +# 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 SqlStoredProcedure(Resource): + """An Azure Cosmos DB stored procedure. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The unique resource identifier of the database account. + :vartype id: str + :ivar name: The name of the database account. + :vartype name: str + :ivar type: The type of Azure resource. + :vartype type: str + :param location: The location of the resource group to which the resource + belongs. + :type location: str + :param tags: + :type tags: dict[str, str] + :param sql_stored_procedure_id: Name of the Sql Stored Procedure + :type sql_stored_procedure_id: str + :param body: Body of the Stored Procedure + :type body: str + :param _rid: A system generated property. A unique identifier. + :type _rid: str + :param _ts: A system generated property that denotes the last updated + timestamp of the resource. + :type _ts: object + :param _etag: A system generated property representing the resource etag + required for optimistic concurrency control. + :type _etag: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sql_stored_procedure_id': {'key': 'properties.id', 'type': 'str'}, + 'body': {'key': 'properties.body', 'type': 'str'}, + '_rid': {'key': 'properties._rid', 'type': 'str'}, + '_ts': {'key': 'properties._ts', 'type': 'object'}, + '_etag': {'key': 'properties._etag', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SqlStoredProcedure, self).__init__(**kwargs) + self.sql_stored_procedure_id = kwargs.get('sql_stored_procedure_id', None) + self.body = kwargs.get('body', None) + self._rid = kwargs.get('_rid', None) + self._ts = kwargs.get('_ts', None) + self._etag = kwargs.get('_etag', None) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_create_update_parameters.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_create_update_parameters.py new file mode 100644 index 000000000000..791d057a037c --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_create_update_parameters.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SqlStoredProcedureCreateUpdateParameters(Model): + """Parameters to create and update Cosmos DB stored procedure. + + All required parameters must be populated in order to send to Azure. + + :param resource: Required. The standard JSON format of a stored procedure + :type resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureResource + :param options: Required. 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] + """ + + _validation = { + 'resource': {'required': True}, + 'options': {'required': True}, + } + + _attribute_map = { + 'resource': {'key': 'properties.resource', 'type': 'SqlStoredProcedureResource'}, + 'options': {'key': 'properties.options', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(SqlStoredProcedureCreateUpdateParameters, self).__init__(**kwargs) + self.resource = kwargs.get('resource', None) + self.options = kwargs.get('options', None) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_create_update_parameters_py3.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_create_update_parameters_py3.py new file mode 100644 index 000000000000..0e40405fe84b --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_create_update_parameters_py3.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SqlStoredProcedureCreateUpdateParameters(Model): + """Parameters to create and update Cosmos DB stored procedure. + + All required parameters must be populated in order to send to Azure. + + :param resource: Required. The standard JSON format of a stored procedure + :type resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureResource + :param options: Required. 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] + """ + + _validation = { + 'resource': {'required': True}, + 'options': {'required': True}, + } + + _attribute_map = { + 'resource': {'key': 'properties.resource', 'type': 'SqlStoredProcedureResource'}, + 'options': {'key': 'properties.options', 'type': '{str}'}, + } + + def __init__(self, *, resource, options, **kwargs) -> None: + super(SqlStoredProcedureCreateUpdateParameters, self).__init__(**kwargs) + self.resource = resource + self.options = options diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_paged.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_paged.py new file mode 100644 index 000000000000..62afa463b391 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class SqlStoredProcedurePaged(Paged): + """ + A paging container for iterating over a list of :class:`SqlStoredProcedure ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[SqlStoredProcedure]'} + } + + def __init__(self, *args, **kwargs): + + super(SqlStoredProcedurePaged, self).__init__(*args, **kwargs) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_py3.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_py3.py new file mode 100644 index 000000000000..67634f8c5d1b --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_py3.py @@ -0,0 +1,71 @@ +# 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 SqlStoredProcedure(Resource): + """An Azure Cosmos DB stored procedure. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The unique resource identifier of the database account. + :vartype id: str + :ivar name: The name of the database account. + :vartype name: str + :ivar type: The type of Azure resource. + :vartype type: str + :param location: The location of the resource group to which the resource + belongs. + :type location: str + :param tags: + :type tags: dict[str, str] + :param sql_stored_procedure_id: Name of the Sql Stored Procedure + :type sql_stored_procedure_id: str + :param body: Body of the Stored Procedure + :type body: str + :param _rid: A system generated property. A unique identifier. + :type _rid: str + :param _ts: A system generated property that denotes the last updated + timestamp of the resource. + :type _ts: object + :param _etag: A system generated property representing the resource etag + required for optimistic concurrency control. + :type _etag: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sql_stored_procedure_id': {'key': 'properties.id', 'type': 'str'}, + 'body': {'key': 'properties.body', 'type': 'str'}, + '_rid': {'key': 'properties._rid', 'type': 'str'}, + '_ts': {'key': 'properties._ts', 'type': 'object'}, + '_etag': {'key': 'properties._etag', 'type': 'str'}, + } + + def __init__(self, *, location: str=None, tags=None, sql_stored_procedure_id: str=None, body: str=None, _rid: str=None, _ts=None, _etag: str=None, **kwargs) -> None: + super(SqlStoredProcedure, self).__init__(location=location, tags=tags, **kwargs) + self.sql_stored_procedure_id = sql_stored_procedure_id + self.body = body + self._rid = _rid + self._ts = _ts + self._etag = _etag diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_resource.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_resource.py new file mode 100644 index 000000000000..746d634c30ff --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_resource.py @@ -0,0 +1,32 @@ +# 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 SqlStoredProcedureResource(Model): + """Cosmos DB Gremlin graph resource object. + + :param id: Name of the Sql Stored Procedure + :type id: str + :param body: Body of the Stored Procedure + :type body: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'body': {'key': 'body', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SqlStoredProcedureResource, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.body = kwargs.get('body', None) diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_resource_py3.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_resource_py3.py new file mode 100644 index 000000000000..a2e59243f7ec --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/sql_stored_procedure_resource_py3.py @@ -0,0 +1,32 @@ +# 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 SqlStoredProcedureResource(Model): + """Cosmos DB Gremlin graph resource object. + + :param id: Name of the Sql Stored Procedure + :type id: str + :param body: Body of the Stored Procedure + :type body: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'body': {'key': 'body', 'type': 'str'}, + } + + def __init__(self, *, id: str=None, body: str=None, **kwargs) -> None: + super(SqlStoredProcedureResource, self).__init__(**kwargs) + self.id = id + self.body = body 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 1386fee66bf7..e96a5828fb48 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 @@ -2443,6 +2443,364 @@ def get_long_running_output(response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) 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_sql_stored_procedures( + self, resource_group_name, account_name, database_name, container_name, custom_headers=None, raw=False, **operation_config): + """Lists the SQL stored procedures 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 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: An iterator like instance of SqlStoredProcedure + :rtype: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedurePaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedure] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_sql_stored_procedures.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, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), + '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) + + # 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.SqlStoredProcedurePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.SqlStoredProcedurePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_sql_stored_procedures.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures'} + + def get_sql_stored_procedure( + self, resource_group_name, account_name, database_name, container_name, stored_procedure_name, custom_headers=None, raw=False, **operation_config): + """Gets the SQL StoredProcedure 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 container_name: Cosmos DB container name. + :type container_name: str + :param stored_procedure_name: Cosmos DB SQL StoredProcedure name + :type stored_procedure_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: SqlStoredProcedure or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.cosmosdb.models.SqlStoredProcedure or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_sql_stored_procedure.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, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'containerName': self._serialize.url("container_name", container_name, 'str'), + 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_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('SqlStoredProcedure', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} + + + def _create_update_sql_stored_procedure_initial( + self, resource_group_name, account_name, database_name, container_name, stored_procedure_name, resource, options, custom_headers=None, raw=False, **operation_config): + create_update_sql_stored_procedure_parameters = models.SqlStoredProcedureCreateUpdateParameters(resource=resource, options=options) + + # Construct URL + url = self.create_update_sql_stored_procedure.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, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'containerName': self._serialize.url("container_name", container_name, 'str'), + 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_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_sql_stored_procedure_parameters, 'SqlStoredProcedureCreateUpdateParameters') + + # 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('SqlStoredProcedure', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_update_sql_stored_procedure( + self, resource_group_name, account_name, database_name, container_name, stored_procedure_name, resource, options, custom_headers=None, raw=False, polling=True, **operation_config): + """Create or update an Azure Cosmos DB SQL StoredProcedure. + + :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 container_name: Cosmos DB container name. + :type container_name: str + :param stored_procedure_name: Cosmos DB SQL StoredProcedure name + :type stored_procedure_name: str + :param resource: The standard JSON format of a stored procedure + :type resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureResource + :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 SqlStoredProcedure or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedure] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.cosmosdb.models.SqlStoredProcedure]] + :raises: :class:`CloudError` + """ + raw_result = self._create_update_sql_stored_procedure_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + stored_procedure_name=stored_procedure_name, + resource=resource, + options=options, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('SqlStoredProcedure', 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_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} + + + def _delete_sql_stored_procedure_initial( + self, resource_group_name, account_name, database_name, container_name, stored_procedure_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete_sql_stored_procedure.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, pattern=r'^[a-z0-9]+(-[a-z0-9]+)*'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'containerName': self._serialize.url("container_name", container_name, 'str'), + 'storedProcedureName': self._serialize.url("stored_procedure_name", stored_procedure_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_sql_stored_procedure( + self, resource_group_name, account_name, database_name, container_name, stored_procedure_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes an existing Azure Cosmos DB SQL StoredProcedure. + + :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 container_name: Cosmos DB container name. + :type container_name: str + :param stored_procedure_name: Cosmos DB SQL StoredProcedure name + :type stored_procedure_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_sql_stored_procedure_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + stored_procedure_name=stored_procedure_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_sql_stored_procedure.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}'} + 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