diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py index ce6f450c6e29d..29c37824309d9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py @@ -102,6 +102,7 @@ from .operations import SyncGroupsOperations from .operations import SyncMembersOperations from .operations import ManagedDatabasesOperations +from .operations import ManagedDatabaseRestoreDetailsOperations from .operations import ServerAzureADOnlyAuthenticationsOperations from .operations import ManagedInstancesOperations from .operations import ManagedInstanceAzureADOnlyAuthenticationsOperations @@ -294,6 +295,8 @@ class SqlManagementClient(SDKClient): :vartype sync_members: azure.mgmt.sql.operations.SyncMembersOperations :ivar managed_databases: ManagedDatabases operations :vartype managed_databases: azure.mgmt.sql.operations.ManagedDatabasesOperations + :ivar managed_database_restore_details: ManagedDatabaseRestoreDetails operations + :vartype managed_database_restore_details: azure.mgmt.sql.operations.ManagedDatabaseRestoreDetailsOperations :ivar server_azure_ad_only_authentications: ServerAzureADOnlyAuthentications operations :vartype server_azure_ad_only_authentications: azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations :ivar managed_instances: ManagedInstances operations @@ -502,6 +505,8 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.managed_databases = ManagedDatabasesOperations( self._client, self.config, self._serialize, self._deserialize) + self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self._client, self.config, self._serialize, self._deserialize) self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self.config, self._serialize, self._deserialize) self.managed_instances = ManagedInstancesOperations( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py index 6292b4ce2d7a1..2b5bb1e9ddc05 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py @@ -84,6 +84,7 @@ from ._models_py3 import LongTermRetentionBackup from ._models_py3 import ManagedBackupShortTermRetentionPolicy from ._models_py3 import ManagedDatabase + from ._models_py3 import ManagedDatabaseRestoreDetailsResult from ._models_py3 import ManagedDatabaseSecurityAlertPolicy from ._models_py3 import ManagedDatabaseUpdate from ._models_py3 import ManagedInstance @@ -281,6 +282,7 @@ from ._models import LongTermRetentionBackup from ._models import ManagedBackupShortTermRetentionPolicy from ._models import ManagedDatabase + from ._models import ManagedDatabaseRestoreDetailsResult from ._models import ManagedDatabaseSecurityAlertPolicy from ._models import ManagedDatabaseUpdate from ._models import ManagedInstance @@ -664,6 +666,7 @@ 'LongTermRetentionBackup', 'ManagedBackupShortTermRetentionPolicy', 'ManagedDatabase', + 'ManagedDatabaseRestoreDetailsResult', 'ManagedDatabaseSecurityAlertPolicy', 'ManagedDatabaseUpdate', 'ManagedInstance', diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py index 2726dfaf92783..efe4a990b55a8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py @@ -4826,6 +4826,86 @@ def __init__(self, **kwargs): self.last_backup_name = kwargs.get('last_backup_name', None) +class ManagedDatabaseRestoreDetailsResult(ProxyResource): + """A managed database restore details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar status: Restore status. + :vartype status: str + :ivar current_restoring_file_name: Current restoring file name. + :vartype current_restoring_file_name: str + :ivar last_restored_file_name: Last restored file name. + :vartype last_restored_file_name: str + :ivar last_restored_file_time: Last restored file time. + :vartype last_restored_file_time: datetime + :ivar percent_completed: Percent completed. + :vartype percent_completed: float + :ivar unrestorable_files: List of unrestorable files. + :vartype unrestorable_files: list[str] + :ivar number_of_files_detected: Number of files detected. + :vartype number_of_files_detected: long + :ivar last_uploaded_file_name: Last uploaded file name. + :vartype last_uploaded_file_name: str + :ivar last_uploaded_file_time: Last uploaded file time. + :vartype last_uploaded_file_time: datetime + :ivar block_reason: The reason why restore is in Blocked state. + :vartype block_reason: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'status': {'readonly': True}, + 'current_restoring_file_name': {'readonly': True}, + 'last_restored_file_name': {'readonly': True}, + 'last_restored_file_time': {'readonly': True}, + 'percent_completed': {'readonly': True}, + 'unrestorable_files': {'readonly': True}, + 'number_of_files_detected': {'readonly': True}, + 'last_uploaded_file_name': {'readonly': True}, + 'last_uploaded_file_time': {'readonly': True}, + 'block_reason': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'current_restoring_file_name': {'key': 'properties.currentRestoringFileName', 'type': 'str'}, + 'last_restored_file_name': {'key': 'properties.lastRestoredFileName', 'type': 'str'}, + 'last_restored_file_time': {'key': 'properties.lastRestoredFileTime', 'type': 'iso-8601'}, + 'percent_completed': {'key': 'properties.percentCompleted', 'type': 'float'}, + 'unrestorable_files': {'key': 'properties.unrestorableFiles', 'type': '[str]'}, + 'number_of_files_detected': {'key': 'properties.numberOfFilesDetected', 'type': 'long'}, + 'last_uploaded_file_name': {'key': 'properties.lastUploadedFileName', 'type': 'str'}, + 'last_uploaded_file_time': {'key': 'properties.lastUploadedFileTime', 'type': 'iso-8601'}, + 'block_reason': {'key': 'properties.blockReason', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ManagedDatabaseRestoreDetailsResult, self).__init__(**kwargs) + self.status = None + self.current_restoring_file_name = None + self.last_restored_file_name = None + self.last_restored_file_time = None + self.percent_completed = None + self.unrestorable_files = None + self.number_of_files_detected = None + self.last_uploaded_file_name = None + self.last_uploaded_file_time = None + self.block_reason = None + + class ManagedDatabaseSecurityAlertPolicy(ProxyResource): """A managed database security alert policy. 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 c2ec30a0a0f20..ae1246f6b91d1 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 @@ -4826,6 +4826,86 @@ def __init__(self, *, location: str, tags=None, collation: str=None, restore_poi self.last_backup_name = last_backup_name +class ManagedDatabaseRestoreDetailsResult(ProxyResource): + """A managed database restore details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar status: Restore status. + :vartype status: str + :ivar current_restoring_file_name: Current restoring file name. + :vartype current_restoring_file_name: str + :ivar last_restored_file_name: Last restored file name. + :vartype last_restored_file_name: str + :ivar last_restored_file_time: Last restored file time. + :vartype last_restored_file_time: datetime + :ivar percent_completed: Percent completed. + :vartype percent_completed: float + :ivar unrestorable_files: List of unrestorable files. + :vartype unrestorable_files: list[str] + :ivar number_of_files_detected: Number of files detected. + :vartype number_of_files_detected: long + :ivar last_uploaded_file_name: Last uploaded file name. + :vartype last_uploaded_file_name: str + :ivar last_uploaded_file_time: Last uploaded file time. + :vartype last_uploaded_file_time: datetime + :ivar block_reason: The reason why restore is in Blocked state. + :vartype block_reason: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'status': {'readonly': True}, + 'current_restoring_file_name': {'readonly': True}, + 'last_restored_file_name': {'readonly': True}, + 'last_restored_file_time': {'readonly': True}, + 'percent_completed': {'readonly': True}, + 'unrestorable_files': {'readonly': True}, + 'number_of_files_detected': {'readonly': True}, + 'last_uploaded_file_name': {'readonly': True}, + 'last_uploaded_file_time': {'readonly': True}, + 'block_reason': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'current_restoring_file_name': {'key': 'properties.currentRestoringFileName', 'type': 'str'}, + 'last_restored_file_name': {'key': 'properties.lastRestoredFileName', 'type': 'str'}, + 'last_restored_file_time': {'key': 'properties.lastRestoredFileTime', 'type': 'iso-8601'}, + 'percent_completed': {'key': 'properties.percentCompleted', 'type': 'float'}, + 'unrestorable_files': {'key': 'properties.unrestorableFiles', 'type': '[str]'}, + 'number_of_files_detected': {'key': 'properties.numberOfFilesDetected', 'type': 'long'}, + 'last_uploaded_file_name': {'key': 'properties.lastUploadedFileName', 'type': 'str'}, + 'last_uploaded_file_time': {'key': 'properties.lastUploadedFileTime', 'type': 'iso-8601'}, + 'block_reason': {'key': 'properties.blockReason', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(ManagedDatabaseRestoreDetailsResult, self).__init__(**kwargs) + self.status = None + self.current_restoring_file_name = None + self.last_restored_file_name = None + self.last_restored_file_time = None + self.percent_completed = None + self.unrestorable_files = None + self.number_of_files_detected = None + self.last_uploaded_file_name = None + self.last_uploaded_file_time = None + self.block_reason = None + + class ManagedDatabaseSecurityAlertPolicy(ProxyResource): """A managed database security alert policy. diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py index 5bf21894193f0..1380f65a6008b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py @@ -98,6 +98,7 @@ from ._sync_groups_operations import SyncGroupsOperations from ._sync_members_operations import SyncMembersOperations from ._managed_databases_operations import ManagedDatabasesOperations +from ._managed_database_restore_details_operations import ManagedDatabaseRestoreDetailsOperations from ._server_azure_ad_only_authentications_operations import ServerAzureADOnlyAuthenticationsOperations from ._managed_instances_operations import ManagedInstancesOperations from ._managed_instance_azure_ad_only_authentications_operations import ManagedInstanceAzureADOnlyAuthenticationsOperations @@ -194,6 +195,7 @@ 'SyncGroupsOperations', 'SyncMembersOperations', 'ManagedDatabasesOperations', + 'ManagedDatabaseRestoreDetailsOperations', 'ServerAzureADOnlyAuthenticationsOperations', 'ManagedInstancesOperations', 'ManagedInstanceAzureADOnlyAuthenticationsOperations', diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_import_export_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_import_export_operations.py deleted file mode 100644 index ce62b16c135ad..0000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_import_export_operations.py +++ /dev/null @@ -1,150 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling - -from .. import models - - -class ImportExportOperations(object): - """ImportExportOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the request. Constant value: "2020-02-02-preview". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2020-02-02-preview" - - self.config = config - - - def _import_method_initial( - self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): - # Construct URL - url = self.import_method.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ImportExistingDatabaseDefinition') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ImportExportOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def import_method( - self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """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. - :type database_name: str - :param parameters: The database import request parameters. - :type parameters: - ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns - ImportExportOperationResult or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.sql.models.ImportExportOperationResult]] - :raises: :class:`CloudError` - """ - raw_result = self._import_method_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config - ) - - def get_long_running_output(response): - deserialized = self._deserialize('ImportExportOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import'} diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py index 16e6a3439aae8..a9c6e09886232 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py @@ -26,7 +26,7 @@ class ManagedDatabaseRestoreDetailsOperations(object): :param serializer: An object model serializer. :param deserializer: An object model deserializer. :ivar restore_details_name: The name of the restore details to retrieve. Constant value: "Default". - :ivar api_version: The API version to use for this operation. Constant value: "2020-02-02-preview". + :ivar api_version: The API version to use for the request. Constant value: "2020-02-02-preview". """ models = models @@ -45,8 +45,9 @@ def get( self, resource_group_name, managed_instance_name, database_name, custom_headers=None, raw=False, **operation_config): """Gets managed database restore details. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :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 managed_instance_name: The name of the managed instance. :type managed_instance_name: str @@ -66,7 +67,7 @@ def get( # Construct URL url = self.get.metadata['url'] path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), 'databaseName': self._serialize.url("database_name", database_name, 'str'), 'restoreDetailsName': self._serialize.url("self.restore_details_name", self.restore_details_name, 'str'), @@ -76,7 +77,7 @@ def get( # Construct parameters query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {}