diff --git a/sdk/sql/azure-mgmt-sql/_meta.json b/sdk/sql/azure-mgmt-sql/_meta.json index c004568ac673..692dd3f32f21 100644 --- a/sdk/sql/azure-mgmt-sql/_meta.json +++ b/sdk/sql/azure-mgmt-sql/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@5.12.0", "@autorest/modelerfour@4.19.3" ], - "commit": "989a7d0e47a71a77d9a8e56f2a3eee0d366b6909", + "commit": "c76db05c209e7e3273990521da05e77fd774174b", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/sql/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/sql/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/sql/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py index 30888d1aebd8..c78e629b6f08 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0b2" +VERSION = "0.9.0" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py index 76f80ba8e330..e911094ec00b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py @@ -704,107 +704,32 @@ def get_long_running_output(pipeline_response): begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore - @distributed_trace - def list_by_elastic_pool( + async def _export_initial( self, resource_group_name: str, server_name: str, - elastic_pool_name: str, + database_name: str, + parameters: "_models.ExportDatabaseDefinition", **kwargs: Any - ) -> AsyncIterable["_models.DatabaseListResult"]: - """Gets a list of databases in an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. - :type resource_group_name: str - :param server_name: The name of the server. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool. - :type elastic_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] + ) -> Optional["_models.ImportExportOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_elastic_pool_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - template_url=self.list_by_elastic_pool.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_list_by_elastic_pool_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_elastic_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases'} # type: ignore + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - async def _failover_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _json = self._serialize.body(parameters, 'ExportDatabaseDefinition') - - request = build_failover_request_initial( + request = build_export_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - replica_type=replica_type, - template_url=self._failover_initial.metadata['url'], + content_type=content_type, + json=_json, + template_url=self._export_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -816,32 +741,38 @@ async def _failover_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore + return deserialized + + _export_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_export( self, resource_group_name: str, server_name: str, database_name: str, - replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, + parameters: "_models.ExportDatabaseDefinition", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Failovers a database. + ) -> AsyncLROPoller["_models.ImportExportOperationResult"]: + """Exports a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database to failover. + :param database_name: The name of the database. :type database_name: str - :param replica_type: The type of replica to be failed over. - :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType + :param parameters: The database export request parameters. + :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -850,31 +781,37 @@ async def begin_failover( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._export_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, - replica_type=replica_type, + parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) @@ -890,102 +827,30 @@ def get_long_running_output(pipeline_response): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore - - @distributed_trace - def list_inaccessible_by_server( - self, - resource_group_name: str, - server_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DatabaseListResult"]: - """Gets a list of inaccessible databases in a logical server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. - :type resource_group_name: str - :param server_name: The name of the server. - :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_inaccessible_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - template_url=self.list_inaccessible_by_server.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_list_inaccessible_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_inaccessible_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases'} # type: ignore + begin_export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore - async def _pause_initial( + async def _failover_initial( self, resource_group_name: str, server_name: str, database_name: str, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, **kwargs: Any - ) -> Optional["_models.Database"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - request = build_pause_request_initial( + request = build_failover_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self._pause_initial.metadata['url'], + replica_type=replica_type, + template_url=self._failover_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -997,35 +862,32 @@ async def _pause_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Database', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, None, {}) - _pause_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore + _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore @distributed_trace_async - async def begin_pause( + async def begin_failover( self, resource_group_name: str, server_name: str, database_name: str, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Database"]: - """Pauses a database. + ) -> AsyncLROPoller[None]: + """Failovers a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database to be paused. + :param database_name: The name of the database to failover. :type database_name: str + :param replica_type: The type of replica to be failed over. + :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1034,34 +896,31 @@ async def begin_pause( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._pause_initial( + raw_result = await self._failover_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, + replica_type=replica_type, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + return cls(pipeline_response, None, {}) if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) @@ -1077,28 +936,34 @@ def get_long_running_output(pipeline_response): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_pause.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore - async def _resume_initial( + async def _import_method_initial( self, resource_group_name: str, server_name: str, database_name: str, + parameters: "_models.ImportExistingDatabaseDefinition", **kwargs: Any - ) -> Optional["_models.Database"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] + ) -> Optional["_models.ImportExportOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - request = build_resume_request_initial( + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') + + request = build_import_method_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self._resume_initial.metadata['url'], + content_type=content_type, + json=_json, + template_url=self._import_method_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1112,33 +977,36 @@ async def _resume_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore + _import_method_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore @distributed_trace_async - async def begin_resume( + async def begin_import_method( self, resource_group_name: str, server_name: str, database_name: str, + parameters: "_models.ImportExistingDatabaseDefinition", **kwargs: Any - ) -> AsyncLROPoller["_models.Database"]: - """Resumes a database. + ) -> AsyncLROPoller["_models.ImportExportOperationResult"]: + """Imports a bacpac into a new database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database to be resumed. + :param database_name: The name of the database. :type database_name: str + :param parameters: The database import request parameters. + :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1147,23 +1015,26 @@ async def begin_resume( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._resume_initial( + raw_result = await self._import_method_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, + parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) @@ -1171,7 +1042,7 @@ async def begin_resume( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized @@ -1190,28 +1061,88 @@ def get_long_running_output(pipeline_response): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore + begin_import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore - async def _upgrade_data_warehouse_initial( + @distributed_trace_async + async def rename( self, resource_group_name: str, server_name: str, database_name: str, + parameters: "_models.ResourceMoveDefinition", **kwargs: Any ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param database_name: The name of the database to rename. + :type database_name: str + :param parameters: The resource move definition for renaming this database. + :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceMoveDefinition') + + request = build_rename_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.rename.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + rename.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move'} # type: ignore + + + async def _pause_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> Optional["_models.Database"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + - request = build_upgrade_data_warehouse_request_initial( + request = build_pause_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self._upgrade_data_warehouse_initial.metadata['url'], + template_url=self._pause_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1223,28 +1154,34 @@ async def _upgrade_data_warehouse_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Database', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - _upgrade_data_warehouse_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore + return deserialized + + _pause_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore @distributed_trace_async - async def begin_upgrade_data_warehouse( + async def begin_pause( self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades a data warehouse. + ) -> AsyncLROPoller["_models.Database"]: + """Pauses a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database to be upgraded. + :param database_name: The name of the database to be paused. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1254,19 +1191,20 @@ async def begin_upgrade_data_warehouse( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._upgrade_data_warehouse_initial( + raw_result = await self._pause_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, @@ -1276,8 +1214,11 @@ async def begin_upgrade_data_warehouse( kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Database', pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) @@ -1293,94 +1234,28 @@ def get_long_running_output(pipeline_response): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_upgrade_data_warehouse.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore - - @distributed_trace_async - async def rename( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: "_models.ResourceMoveDefinition", - **kwargs: Any - ) -> None: - """Renames a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. - :type resource_group_name: str - :param server_name: The name of the server. - :type server_name: str - :param database_name: The name of the database to rename. - :type database_name: str - :param parameters: The resource move definition for renaming this database. - :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ResourceMoveDefinition') - - request = build_rename_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - json=_json, - template_url=self.rename.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - rename.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move'} # type: ignore - + begin_pause.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore - async def _import_method_initial( + async def _resume_initial( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ImportExistingDatabaseDefinition", **kwargs: Any - ) -> Optional["_models.ImportExportOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] + ) -> Optional["_models.Database"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') - - request = build_import_method_request_initial( + + request = build_resume_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - content_type=content_type, - json=_json, - template_url=self._import_method_initial.metadata['url'], + template_url=self._resume_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1394,36 +1269,33 @@ async def _import_method_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) + deserialized = self._deserialize('Database', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _import_method_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore + _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore @distributed_trace_async - async def begin_import_method( + async def begin_resume( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ImportExistingDatabaseDefinition", **kwargs: Any - ) -> AsyncLROPoller["_models.ImportExportOperationResult"]: - """Imports a bacpac into a new database. + ) -> AsyncLROPoller["_models.Database"]: + """Resumes a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database. + :param database_name: The name of the database to be resumed. :type database_name: str - :param parameters: The database import request parameters. - :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1432,26 +1304,23 @@ async def begin_import_method( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._import_method_initial( + raw_result = await self._resume_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, - parameters=parameters, - content_type=content_type, cls=lambda x,y,z: x, **kwargs ) @@ -1459,7 +1328,7 @@ async def begin_import_method( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) + deserialized = self._deserialize('Database', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized @@ -1478,34 +1347,28 @@ def get_long_running_output(pipeline_response): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore + begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore - async def _export_initial( + async def _upgrade_data_warehouse_initial( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ExportDatabaseDefinition", **kwargs: Any - ) -> Optional["_models.ImportExportOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ExportDatabaseDefinition') - - request = build_export_request_initial( + + request = build_upgrade_data_warehouse_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - content_type=content_type, - json=_json, - template_url=self._export_initial.metadata['url'], + template_url=self._upgrade_data_warehouse_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1517,38 +1380,29 @@ async def _export_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, None, {}) - _export_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore + _upgrade_data_warehouse_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore @distributed_trace_async - async def begin_export( + async def begin_upgrade_data_warehouse( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ExportDatabaseDefinition", **kwargs: Any - ) -> AsyncLROPoller["_models.ImportExportOperationResult"]: - """Exports a database. + ) -> AsyncLROPoller[None]: + """Upgrades a data warehouse. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database. + :param database_name: The name of the database to be upgraded. :type database_name: str - :param parameters: The database export request parameters. - :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1557,37 +1411,30 @@ async def begin_export( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._export_initial( + raw_result = await self._upgrade_data_warehouse_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, - parameters=parameters, - content_type=content_type, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + return cls(pipeline_response, None, {}) if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) @@ -1603,4 +1450,157 @@ def get_long_running_output(pipeline_response): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore + begin_upgrade_data_warehouse.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore + + @distributed_trace + def list_by_elastic_pool( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.DatabaseListResult"]: + """Gets a list of databases in an elastic pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param elastic_pool_name: The name of the elastic pool. + :type elastic_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatabaseListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DatabaseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_elastic_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases'} # type: ignore + + @distributed_trace + def list_inaccessible_by_server( + self, + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.DatabaseListResult"]: + """Gets a list of inaccessible databases in a logical server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatabaseListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_inaccessible_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DatabaseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_inaccessible_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py index d9617616b321..7f0c3d38e87a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py @@ -880,10 +880,12 @@ class Database(TrackedResource): :vartype earliest_restore_date: ~datetime.datetime :ivar read_scale: The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica - in the same region. Possible values include: "Enabled", "Disabled". + in the same region. Not applicable to a Hyperscale database within an elastic pool. Possible + values include: "Enabled", "Disabled". :vartype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale :ivar high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. + database that are used to provide high availability. Not applicable to a Hyperscale database + within an elastic pool. :vartype high_availability_replica_count: int :ivar secondary_type: The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: "Geo", "Named". @@ -923,6 +925,30 @@ class Database(TrackedResource): :ivar primary_delegated_identity_client_id: The Primary Delegated Identity Client id used for per database CMK - for internal use only. :vartype primary_delegated_identity_client_id: str + :ivar source_resource_id: The resource identifier of the source associated with the create + operation of this database. + + When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, + restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode + must be PointInTimeRestore, Restore or Recover. + + When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of an existing + database or existing sql pool, and restorePointInTime must be specified. + + When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped + database or restorable dropped sql pool. + + When createMode is Recover, sourceResourceId must be the resource ID of recoverable database + or recoverable sql pool. + + This property allows to restore across subscriptions which is only supported for DataWarehouse + edition. + + When source subscription belongs to a different tenant than target subscription, + “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. + For more details about “x-ms-authorization-auxiliary” header see + https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant. + :vartype source_resource_id: str """ _validation = { @@ -997,6 +1023,7 @@ class Database(TrackedResource): 'is_infra_encryption_enabled': {'key': 'properties.isInfraEncryptionEnabled', 'type': 'bool'}, 'federated_client_id': {'key': 'properties.federatedClientId', 'type': 'str'}, 'primary_delegated_identity_client_id': {'key': 'properties.primaryDelegatedIdentityClientId', 'type': 'str'}, + 'source_resource_id': {'key': 'properties.sourceResourceId', 'type': 'str'}, } def __init__( @@ -1031,6 +1058,7 @@ def __init__( is_ledger_on: Optional[bool] = None, federated_client_id: Optional[str] = None, primary_delegated_identity_client_id: Optional[str] = None, + source_resource_id: Optional[str] = None, **kwargs ): """ @@ -1130,10 +1158,12 @@ def __init__( :paramtype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType :keyword read_scale: The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly - secondary replica in the same region. Possible values include: "Enabled", "Disabled". + secondary replica in the same region. Not applicable to a Hyperscale database within an elastic + pool. Possible values include: "Enabled", "Disabled". :paramtype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale :keyword high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. + database that are used to provide high availability. Not applicable to a Hyperscale database + within an elastic pool. :paramtype high_availability_replica_count: int :keyword secondary_type: The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: "Geo", "Named". @@ -1160,6 +1190,30 @@ def __init__( :keyword primary_delegated_identity_client_id: The Primary Delegated Identity Client id used for per database CMK - for internal use only. :paramtype primary_delegated_identity_client_id: str + :keyword source_resource_id: The resource identifier of the source associated with the create + operation of this database. + + When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, + restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode + must be PointInTimeRestore, Restore or Recover. + + When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of an existing + database or existing sql pool, and restorePointInTime must be specified. + + When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped + database or restorable dropped sql pool. + + When createMode is Recover, sourceResourceId must be the resource ID of recoverable database + or recoverable sql pool. + + This property allows to restore across subscriptions which is only supported for DataWarehouse + edition. + + When source subscription belongs to a different tenant than target subscription, + “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. + For more details about “x-ms-authorization-auxiliary” header see + https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant. + :paramtype source_resource_id: str """ super(Database, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku @@ -1205,6 +1259,7 @@ def __init__( self.is_infra_encryption_enabled = None self.federated_client_id = federated_client_id self.primary_delegated_identity_client_id = primary_delegated_identity_client_id + self.source_resource_id = source_resource_id class DatabaseAutomaticTuning(ProxyResource): @@ -2279,7 +2334,7 @@ def __init__( class DatabaseUpdate(msrest.serialization.Model): - """A database resource. + """A database update resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2386,10 +2441,12 @@ class DatabaseUpdate(msrest.serialization.Model): :vartype earliest_restore_date: ~datetime.datetime :ivar read_scale: The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica - in the same region. Possible values include: "Enabled", "Disabled". + in the same region. Not applicable to a Hyperscale database within an elastic pool. Possible + values include: "Enabled", "Disabled". :vartype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale :ivar high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. + database that are used to provide high availability. Not applicable to a Hyperscale database + within an elastic pool. :vartype high_availability_replica_count: int :ivar secondary_type: The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: "Geo", "Named". @@ -2606,10 +2663,12 @@ def __init__( :paramtype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType :keyword read_scale: The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly - secondary replica in the same region. Possible values include: "Enabled", "Disabled". + secondary replica in the same region. Not applicable to a Hyperscale database within an elastic + pool. Possible values include: "Enabled", "Disabled". :paramtype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale :keyword high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. + database that are used to provide high availability. Not applicable to a Hyperscale database + within an elastic pool. :paramtype high_availability_replica_count: int :keyword secondary_type: The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: "Geo", "Named". diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py index a271e38af484..c15fa5948160 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py @@ -279,7 +279,7 @@ class DatabaseLicenseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): class DatabaseReadScale(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same - region. + region. Not applicable to a Hyperscale database within an elastic pool. """ ENABLED = "Enabled" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py index 3efe2527ae7c..ed5737f272f0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py @@ -305,21 +305,26 @@ def build_update_request_initial( ) -def build_list_by_elastic_pool_request( +def build_export_request_initial( resource_group_name: str, server_name: str, - elastic_pool_name: str, + database_name: str, subscription_id: str, + *, + json: JSONType = None, + content: Any = None, **kwargs: Any ) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = "2021-05-01-preview" accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases') + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export') path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serverName": _SERIALIZER.url("server_name", server_name, 'str'), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } @@ -331,13 +336,17 @@ def build_list_by_elastic_pool_request( # Construct headers header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( - method="GET", + method="POST", url=url, params=query_parameters, headers=header_parameters, + json=json, + content=content, **kwargs ) @@ -377,19 +386,26 @@ def build_failover_request_initial( ) -def build_list_inaccessible_by_server_request( +def build_import_method_request_initial( resource_group_name: str, server_name: str, + database_name: str, subscription_id: str, + *, + json: JSONType = None, + content: Any = None, **kwargs: Any ) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = "2021-05-01-preview" accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases') + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import') path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } @@ -401,28 +417,36 @@ def build_list_inaccessible_by_server_request( # Construct headers header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( - method="GET", + method="POST", url=url, params=query_parameters, headers=header_parameters, + json=json, + content=content, **kwargs ) -def build_pause_request_initial( +def build_rename_request( resource_group_name: str, server_name: str, database_name: str, subscription_id: str, + *, + json: JSONType = None, + content: Any = None, **kwargs: Any ) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = "2021-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause') + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move') path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serverName": _SERIALIZER.url("server_name", server_name, 'str'), @@ -438,18 +462,21 @@ def build_pause_request_initial( # Construct headers header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=url, params=query_parameters, headers=header_parameters, + json=json, + content=content, **kwargs ) -def build_resume_request_initial( +def build_pause_request_initial( resource_group_name: str, server_name: str, database_name: str, @@ -459,7 +486,7 @@ def build_resume_request_initial( api_version = "2021-05-01-preview" accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume') + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause') path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serverName": _SERIALIZER.url("server_name", server_name, 'str'), @@ -486,7 +513,7 @@ def build_resume_request_initial( ) -def build_upgrade_data_warehouse_request_initial( +def build_resume_request_initial( resource_group_name: str, server_name: str, database_name: str, @@ -494,8 +521,9 @@ def build_upgrade_data_warehouse_request_initial( **kwargs: Any ) -> HttpRequest: api_version = "2021-05-01-preview" + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse') + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume') path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serverName": _SERIALIZER.url("server_name", server_name, 'str'), @@ -509,29 +537,29 @@ def build_upgrade_data_warehouse_request_initial( query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + return HttpRequest( method="POST", url=url, params=query_parameters, + headers=header_parameters, **kwargs ) -def build_rename_request( +def build_upgrade_data_warehouse_request_initial( resource_group_name: str, server_name: str, database_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-05-01-preview" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move') + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse') path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serverName": _SERIALIZER.url("server_name", server_name, 'str'), @@ -545,42 +573,29 @@ def build_rename_request( query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - return HttpRequest( method="POST", url=url, params=query_parameters, - headers=header_parameters, - json=json, - content=content, **kwargs ) -def build_import_method_request_initial( +def build_list_by_elastic_pool_request( resource_group_name: str, server_name: str, - database_name: str, + elastic_pool_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-05-01-preview" accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import') + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases') path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serverName": _SERIALIZER.url("server_name", server_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } @@ -592,41 +607,30 @@ def build_import_method_request_initial( # Construct headers header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( - method="POST", + method="GET", url=url, params=query_parameters, headers=header_parameters, - json=json, - content=content, **kwargs ) -def build_export_request_initial( +def build_list_inaccessible_by_server_request( resource_group_name: str, server_name: str, - database_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-05-01-preview" accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export') + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases') path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serverName": _SERIALIZER.url("server_name", server_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } @@ -638,17 +642,13 @@ def build_export_request_initial( # Construct headers header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( - method="POST", + method="GET", url=url, params=query_parameters, headers=header_parameters, - json=json, - content=content, **kwargs ) @@ -1327,107 +1327,32 @@ def get_long_running_output(pipeline_response): begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}'} # type: ignore - @distributed_trace - def list_by_elastic_pool( + def _export_initial( self, resource_group_name: str, server_name: str, - elastic_pool_name: str, + database_name: str, + parameters: "_models.ExportDatabaseDefinition", **kwargs: Any - ) -> Iterable["_models.DatabaseListResult"]: - """Gets a list of databases in an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. - :type resource_group_name: str - :param server_name: The name of the server. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool. - :type elastic_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] + ) -> Optional["_models.ImportExportOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_elastic_pool_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - template_url=self.list_by_elastic_pool.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_list_by_elastic_pool_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_elastic_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases'} # type: ignore + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - def _failover_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _json = self._serialize.body(parameters, 'ExportDatabaseDefinition') - - request = build_failover_request_initial( + request = build_export_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - replica_type=replica_type, - template_url=self._failover_initial.metadata['url'], + content_type=content_type, + json=_json, + template_url=self._export_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1439,32 +1364,38 @@ def _failover_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore + return deserialized + + _export_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore @distributed_trace - def begin_failover( + def begin_export( self, resource_group_name: str, server_name: str, database_name: str, - replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, + parameters: "_models.ExportDatabaseDefinition", **kwargs: Any - ) -> LROPoller[None]: - """Failovers a database. + ) -> LROPoller["_models.ImportExportOperationResult"]: + """Exports a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database to failover. + :param database_name: The name of the database. :type database_name: str - :param replica_type: The type of replica to be failed over. - :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType + :param parameters: The database export request parameters. + :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1473,32 +1404,38 @@ def begin_failover( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either ImportExportOperationResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._export_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, - replica_type=replica_type, + parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) if cls: - return cls(pipeline_response, None, {}) - + return cls(pipeline_response, deserialized, {}) + return deserialized + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() @@ -1513,102 +1450,30 @@ def get_long_running_output(pipeline_response): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore - - @distributed_trace - def list_inaccessible_by_server( - self, - resource_group_name: str, - server_name: str, - **kwargs: Any - ) -> Iterable["_models.DatabaseListResult"]: - """Gets a list of inaccessible databases in a logical server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. - :type resource_group_name: str - :param server_name: The name of the server. - :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_inaccessible_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - template_url=self.list_inaccessible_by_server.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_list_inaccessible_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_inaccessible_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases'} # type: ignore + begin_export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore - def _pause_initial( + def _failover_initial( self, resource_group_name: str, server_name: str, database_name: str, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, **kwargs: Any - ) -> Optional["_models.Database"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - request = build_pause_request_initial( + request = build_failover_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self._pause_initial.metadata['url'], + replica_type=replica_type, + template_url=self._failover_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1620,35 +1485,32 @@ def _pause_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Database', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, None, {}) - _pause_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore + _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore @distributed_trace - def begin_pause( + def begin_failover( self, resource_group_name: str, server_name: str, database_name: str, + replica_type: Optional[Union[str, "_models.ReplicaType"]] = None, **kwargs: Any - ) -> LROPoller["_models.Database"]: - """Pauses a database. + ) -> LROPoller[None]: + """Failovers a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database to be paused. + :param database_name: The name of the database to failover. :type database_name: str + :param replica_type: The type of replica to be failed over. + :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1657,33 +1519,31 @@ def begin_pause( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._pause_initial( + raw_result = self._failover_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, + replica_type=replica_type, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + return cls(pipeline_response, None, {}) if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) @@ -1699,28 +1559,34 @@ def get_long_running_output(pipeline_response): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_pause.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore + begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover'} # type: ignore - def _resume_initial( + def _import_method_initial( self, resource_group_name: str, server_name: str, database_name: str, + parameters: "_models.ImportExistingDatabaseDefinition", **kwargs: Any - ) -> Optional["_models.Database"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] + ) -> Optional["_models.ImportExportOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - request = build_resume_request_initial( + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') + + request = build_import_method_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self._resume_initial.metadata['url'], + content_type=content_type, + json=_json, + template_url=self._import_method_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1734,33 +1600,36 @@ def _resume_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore + _import_method_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore @distributed_trace - def begin_resume( + def begin_import_method( self, resource_group_name: str, server_name: str, database_name: str, + parameters: "_models.ImportExistingDatabaseDefinition", **kwargs: Any - ) -> LROPoller["_models.Database"]: - """Resumes a database. + ) -> LROPoller["_models.ImportExportOperationResult"]: + """Imports a bacpac into a new database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database to be resumed. + :param database_name: The name of the database. :type database_name: str + :param parameters: The database import request parameters. + :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1769,22 +1638,26 @@ def begin_resume( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :return: An instance of LROPoller that returns either ImportExportOperationResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._resume_initial( + raw_result = self._import_method_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, + parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) @@ -1792,7 +1665,7 @@ def begin_resume( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized @@ -1811,28 +1684,51 @@ def get_long_running_output(pipeline_response): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore + begin_import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore - def _upgrade_data_warehouse_initial( + @distributed_trace + def rename( self, resource_group_name: str, server_name: str, database_name: str, + parameters: "_models.ResourceMoveDefinition", **kwargs: Any ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param database_name: The name of the database to rename. + :type database_name: str + :param parameters: The resource move definition for renaming this database. + :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - request = build_upgrade_data_warehouse_request_initial( + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceMoveDefinition') + + request = build_rename_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self._upgrade_data_warehouse_initial.metadata['url'], + content_type=content_type, + json=_json, + template_url=self.rename.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1840,168 +1736,148 @@ def _upgrade_data_warehouse_initial( pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _upgrade_data_warehouse_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore + rename.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move'} # type: ignore - @distributed_trace - def begin_upgrade_data_warehouse( + def _pause_initial( self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Upgrades a data warehouse. + ) -> Optional["_models.Database"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. - :type resource_group_name: str - :param server_name: The name of the server. - :type server_name: str - :param database_name: The name of the database to be upgraded. - :type database_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + request = build_pause_request_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + template_url=self._pause_initial.metadata['url'], ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._upgrade_data_warehouse_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Database', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _pause_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore - begin_upgrade_data_warehouse.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore @distributed_trace - def rename( + def begin_pause( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ResourceMoveDefinition", **kwargs: Any - ) -> None: - """Renames a database. + ) -> LROPoller["_models.Database"]: + """Pauses a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database to rename. + :param database_name: The name of the database to be paused. :type database_name: str - :param parameters: The resource move definition for renaming this database. - :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ResourceMoveDefinition') - - request = build_rename_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - json=_json, - template_url=self.rename.metadata['url'], + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._pause_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Database', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - if cls: - return cls(pipeline_response, None, {}) - rename.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move'} # type: ignore + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_pause.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause'} # type: ignore - def _import_method_initial( + def _resume_initial( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ImportExistingDatabaseDefinition", **kwargs: Any - ) -> Optional["_models.ImportExportOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] + ) -> Optional["_models.Database"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') - - request = build_import_method_request_initial( + + request = build_resume_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - content_type=content_type, - json=_json, - template_url=self._import_method_initial.metadata['url'], + template_url=self._resume_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -2015,36 +1891,33 @@ def _import_method_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) + deserialized = self._deserialize('Database', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _import_method_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore + _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore @distributed_trace - def begin_import_method( + def begin_resume( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ImportExistingDatabaseDefinition", **kwargs: Any - ) -> LROPoller["_models.ImportExportOperationResult"]: - """Imports a bacpac into a new database. + ) -> LROPoller["_models.Database"]: + """Resumes a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database. + :param database_name: The name of the database to be resumed. :type database_name: str - :param parameters: The database import request parameters. - :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2053,26 +1926,22 @@ def begin_import_method( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :return: An instance of LROPoller that returns either Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._import_method_initial( + raw_result = self._resume_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, - parameters=parameters, - content_type=content_type, cls=lambda x,y,z: x, **kwargs ) @@ -2080,7 +1949,7 @@ def begin_import_method( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) + deserialized = self._deserialize('Database', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized @@ -2099,34 +1968,28 @@ def get_long_running_output(pipeline_response): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} # type: ignore + begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume'} # type: ignore - def _export_initial( + def _upgrade_data_warehouse_initial( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ExportDatabaseDefinition", **kwargs: Any - ) -> Optional["_models.ImportExportOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImportExportOperationResult"]] + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ExportDatabaseDefinition') - - request = build_export_request_initial( + + request = build_upgrade_data_warehouse_request_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, subscription_id=self._config.subscription_id, - content_type=content_type, - json=_json, - template_url=self._export_initial.metadata['url'], + template_url=self._upgrade_data_warehouse_initial.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -2138,38 +2001,29 @@ def _export_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, None, {}) - _export_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore + _upgrade_data_warehouse_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore @distributed_trace - def begin_export( + def begin_upgrade_data_warehouse( self, resource_group_name: str, server_name: str, database_name: str, - parameters: "_models.ExportDatabaseDefinition", **kwargs: Any - ) -> LROPoller["_models.ImportExportOperationResult"]: - """Exports a database. + ) -> LROPoller[None]: + """Upgrades a data warehouse. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the database. + :param database_name: The name of the database to be upgraded. :type database_name: str - :param parameters: The database export request parameters. - :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2178,37 +2032,30 @@ def begin_export( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportExportOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._export_initial( + raw_result = self._upgrade_data_warehouse_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, - parameters=parameters, - content_type=content_type, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ImportExportOperationResult', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + return cls(pipeline_response, None, {}) if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) @@ -2224,4 +2071,157 @@ def get_long_running_output(pipeline_response): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export'} # type: ignore + begin_upgrade_data_warehouse.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse'} # type: ignore + + @distributed_trace + def list_by_elastic_pool( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseListResult"]: + """Gets a list of databases in an elastic pool. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param elastic_pool_name: The name of the elastic pool. + :type elastic_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatabaseListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_elastic_pool.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_elastic_pool_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DatabaseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_elastic_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases'} # type: ignore + + @distributed_trace + def list_inaccessible_by_server( + self, + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.DatabaseListResult"]: + """Gets a list of inaccessible databases in a logical server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatabaseListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=self.list_inaccessible_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DatabaseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_inaccessible_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases'} # type: ignore