diff --git a/sdk/sql/azure-mgmt-sql/_meta.json b/sdk/sql/azure-mgmt-sql/_meta.json index 05c8c8d78316..5e571cbd1b43 100644 --- a/sdk/sql/azure-mgmt-sql/_meta.json +++ b/sdk/sql/azure-mgmt-sql/_meta.json @@ -4,7 +4,7 @@ "@autorest/python@5.8.4", "@autorest/modelerfour@4.19.2" ], - "commit": "cc268fe6b328f3857edb3ec9bce796e7ffc11f85", + "commit": "035dcd8dffaa0a0ff8b24596536e520101949c15", "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/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", "readme": "specification/sql/resource-manager/readme.md" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_metadata.json b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_metadata.json index 4d0c4303c3ab..6e20fa279947 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_metadata.json +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_metadata.json @@ -1,6 +1,6 @@ { "chosen_version": "", - "total_api_version_list": ["2014-04-01", "2020-11-01-preview", "2021-02-01-preview"], + "total_api_version_list": ["2014-04-01", "2020-11-01-preview", "2021-02-01-preview", "2021-05-01-preview"], "client": { "name": "SqlManagementClient", "filename": "_sql_management_client", @@ -99,7 +99,6 @@ }, "operation_groups": { "recoverable_databases": "RecoverableDatabasesOperations", - "server_connection_policies": "ServerConnectionPoliciesOperations", "data_masking_policies": "DataMaskingPoliciesOperations", "data_masking_rules": "DataMaskingRulesOperations", "geo_backup_policies": "GeoBackupPoliciesOperations", @@ -110,8 +109,6 @@ "service_objectives": "ServiceObjectivesOperations", "elastic_pool_activities": "ElasticPoolActivitiesOperations", "elastic_pool_database_activities": "ElasticPoolDatabaseActivitiesOperations", - "transparent_data_encryptions": "TransparentDataEncryptionsOperations", - "transparent_data_encryption_activities": "TransparentDataEncryptionActivitiesOperations", "server_usages": "ServerUsagesOperations", "extended_database_blob_auditing_policies": "ExtendedDatabaseBlobAuditingPoliciesOperations", "extended_server_blob_auditing_policies": "ExtendedServerBlobAuditingPoliciesOperations", @@ -208,6 +205,7 @@ "virtual_network_rules": "VirtualNetworkRulesOperations", "workload_classifiers": "WorkloadClassifiersOperations", "workload_groups": "WorkloadGroupsOperations", + "transparent_data_encryptions": "TransparentDataEncryptionsOperations", "backup_short_term_retention_policies": "BackupShortTermRetentionPoliciesOperations", "database_extensions": "DatabaseExtensionsOperations", "database_operations": "DatabaseOperationsOperations", @@ -217,6 +215,7 @@ "restorable_dropped_databases": "RestorableDroppedDatabasesOperations", "restorable_dropped_managed_databases": "RestorableDroppedManagedDatabasesOperations", "servers": "ServersOperations", - "usages": "UsagesOperations" + "usages": "UsagesOperations", + "server_connection_policies": "ServerConnectionPoliciesOperations" } } \ No newline at end of file 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 7cc74c21d044..71552954eb41 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 @@ -20,7 +20,6 @@ from ._configuration import SqlManagementClientConfiguration from .operations import RecoverableDatabasesOperations -from .operations import ServerConnectionPoliciesOperations from .operations import DataMaskingPoliciesOperations from .operations import DataMaskingRulesOperations from .operations import GeoBackupPoliciesOperations @@ -31,8 +30,6 @@ from .operations import ServiceObjectivesOperations from .operations import ElasticPoolActivitiesOperations from .operations import ElasticPoolDatabaseActivitiesOperations -from .operations import TransparentDataEncryptionsOperations -from .operations import TransparentDataEncryptionActivitiesOperations from .operations import ServerUsagesOperations from .operations import ExtendedDatabaseBlobAuditingPoliciesOperations from .operations import ExtendedServerBlobAuditingPoliciesOperations @@ -129,6 +126,7 @@ from .operations import VirtualNetworkRulesOperations from .operations import WorkloadClassifiersOperations from .operations import WorkloadGroupsOperations +from .operations import TransparentDataEncryptionsOperations from .operations import BackupShortTermRetentionPoliciesOperations from .operations import DatabaseExtensionsOperations from .operations import DatabaseOperationsOperations @@ -139,6 +137,7 @@ from .operations import RestorableDroppedManagedDatabasesOperations from .operations import ServersOperations from .operations import UsagesOperations +from .operations import ServerConnectionPoliciesOperations from . import models @@ -147,8 +146,6 @@ class SqlManagementClient(object): :ivar recoverable_databases: RecoverableDatabasesOperations operations :vartype recoverable_databases: azure.mgmt.sql.operations.RecoverableDatabasesOperations - :ivar server_connection_policies: ServerConnectionPoliciesOperations operations - :vartype server_connection_policies: azure.mgmt.sql.operations.ServerConnectionPoliciesOperations :ivar data_masking_policies: DataMaskingPoliciesOperations operations :vartype data_masking_policies: azure.mgmt.sql.operations.DataMaskingPoliciesOperations :ivar data_masking_rules: DataMaskingRulesOperations operations @@ -169,10 +166,6 @@ class SqlManagementClient(object): :vartype elastic_pool_activities: azure.mgmt.sql.operations.ElasticPoolActivitiesOperations :ivar elastic_pool_database_activities: ElasticPoolDatabaseActivitiesOperations operations :vartype elastic_pool_database_activities: azure.mgmt.sql.operations.ElasticPoolDatabaseActivitiesOperations - :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations - :vartype transparent_data_encryptions: azure.mgmt.sql.operations.TransparentDataEncryptionsOperations - :ivar transparent_data_encryption_activities: TransparentDataEncryptionActivitiesOperations operations - :vartype transparent_data_encryption_activities: azure.mgmt.sql.operations.TransparentDataEncryptionActivitiesOperations :ivar server_usages: ServerUsagesOperations operations :vartype server_usages: azure.mgmt.sql.operations.ServerUsagesOperations :ivar extended_database_blob_auditing_policies: ExtendedDatabaseBlobAuditingPoliciesOperations operations @@ -365,6 +358,8 @@ class SqlManagementClient(object): :vartype workload_classifiers: azure.mgmt.sql.operations.WorkloadClassifiersOperations :ivar workload_groups: WorkloadGroupsOperations operations :vartype workload_groups: azure.mgmt.sql.operations.WorkloadGroupsOperations + :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations + :vartype transparent_data_encryptions: azure.mgmt.sql.operations.TransparentDataEncryptionsOperations :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations operations :vartype backup_short_term_retention_policies: azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations :ivar database_extensions: DatabaseExtensionsOperations operations @@ -385,6 +380,8 @@ class SqlManagementClient(object): :vartype servers: azure.mgmt.sql.operations.ServersOperations :ivar usages: UsagesOperations operations :vartype usages: azure.mgmt.sql.operations.UsagesOperations + :ivar server_connection_policies: ServerConnectionPoliciesOperations operations + :vartype server_connection_policies: azure.mgmt.sql.operations.ServerConnectionPoliciesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription ID that identifies an Azure subscription. @@ -413,8 +410,6 @@ def __init__( self.recoverable_databases = RecoverableDatabasesOperations( self._client, self._config, self._serialize, self._deserialize) - self.server_connection_policies = ServerConnectionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) self.data_masking_policies = DataMaskingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize) self.data_masking_rules = DataMaskingRulesOperations( @@ -435,10 +430,6 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( self._client, self._config, self._serialize, self._deserialize) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.transparent_data_encryption_activities = TransparentDataEncryptionActivitiesOperations( - self._client, self._config, self._serialize, self._deserialize) self.server_usages = ServerUsagesOperations( self._client, self._config, self._serialize, self._deserialize) self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( @@ -631,6 +622,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.workload_groups = WorkloadGroupsOperations( self._client, self._config, self._serialize, self._deserialize) + self.transparent_data_encryptions = TransparentDataEncryptionsOperations( + self._client, self._config, self._serialize, self._deserialize) self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize) self.database_extensions = DatabaseExtensionsOperations( @@ -651,6 +644,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.usages = UsagesOperations( self._client, self._config, self._serialize, self._deserialize) + self.server_connection_policies = ServerConnectionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize) def _send_request(self, http_request, **kwargs): # type: (HttpRequest, Any) -> HttpResponse 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 42cbaea39a1c..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 = "3.0.1" +VERSION = "0.9.0" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_sql_management_client.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_sql_management_client.py index c43d2b6edb43..d076e3d43c3c 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_sql_management_client.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_sql_management_client.py @@ -18,7 +18,6 @@ from ._configuration import SqlManagementClientConfiguration from .operations import RecoverableDatabasesOperations -from .operations import ServerConnectionPoliciesOperations from .operations import DataMaskingPoliciesOperations from .operations import DataMaskingRulesOperations from .operations import GeoBackupPoliciesOperations @@ -29,8 +28,6 @@ from .operations import ServiceObjectivesOperations from .operations import ElasticPoolActivitiesOperations from .operations import ElasticPoolDatabaseActivitiesOperations -from .operations import TransparentDataEncryptionsOperations -from .operations import TransparentDataEncryptionActivitiesOperations from .operations import ServerUsagesOperations from .operations import ExtendedDatabaseBlobAuditingPoliciesOperations from .operations import ExtendedServerBlobAuditingPoliciesOperations @@ -127,6 +124,7 @@ from .operations import VirtualNetworkRulesOperations from .operations import WorkloadClassifiersOperations from .operations import WorkloadGroupsOperations +from .operations import TransparentDataEncryptionsOperations from .operations import BackupShortTermRetentionPoliciesOperations from .operations import DatabaseExtensionsOperations from .operations import DatabaseOperationsOperations @@ -137,6 +135,7 @@ from .operations import RestorableDroppedManagedDatabasesOperations from .operations import ServersOperations from .operations import UsagesOperations +from .operations import ServerConnectionPoliciesOperations from .. import models @@ -145,8 +144,6 @@ class SqlManagementClient(object): :ivar recoverable_databases: RecoverableDatabasesOperations operations :vartype recoverable_databases: azure.mgmt.sql.aio.operations.RecoverableDatabasesOperations - :ivar server_connection_policies: ServerConnectionPoliciesOperations operations - :vartype server_connection_policies: azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations :ivar data_masking_policies: DataMaskingPoliciesOperations operations :vartype data_masking_policies: azure.mgmt.sql.aio.operations.DataMaskingPoliciesOperations :ivar data_masking_rules: DataMaskingRulesOperations operations @@ -167,10 +164,6 @@ class SqlManagementClient(object): :vartype elastic_pool_activities: azure.mgmt.sql.aio.operations.ElasticPoolActivitiesOperations :ivar elastic_pool_database_activities: ElasticPoolDatabaseActivitiesOperations operations :vartype elastic_pool_database_activities: azure.mgmt.sql.aio.operations.ElasticPoolDatabaseActivitiesOperations - :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations - :vartype transparent_data_encryptions: azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations - :ivar transparent_data_encryption_activities: TransparentDataEncryptionActivitiesOperations operations - :vartype transparent_data_encryption_activities: azure.mgmt.sql.aio.operations.TransparentDataEncryptionActivitiesOperations :ivar server_usages: ServerUsagesOperations operations :vartype server_usages: azure.mgmt.sql.aio.operations.ServerUsagesOperations :ivar extended_database_blob_auditing_policies: ExtendedDatabaseBlobAuditingPoliciesOperations operations @@ -363,6 +356,8 @@ class SqlManagementClient(object): :vartype workload_classifiers: azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations :ivar workload_groups: WorkloadGroupsOperations operations :vartype workload_groups: azure.mgmt.sql.aio.operations.WorkloadGroupsOperations + :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations + :vartype transparent_data_encryptions: azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations operations :vartype backup_short_term_retention_policies: azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations :ivar database_extensions: DatabaseExtensionsOperations operations @@ -383,6 +378,8 @@ class SqlManagementClient(object): :vartype servers: azure.mgmt.sql.aio.operations.ServersOperations :ivar usages: UsagesOperations operations :vartype usages: azure.mgmt.sql.aio.operations.UsagesOperations + :ivar server_connection_policies: ServerConnectionPoliciesOperations operations + :vartype server_connection_policies: azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription ID that identifies an Azure subscription. @@ -410,8 +407,6 @@ def __init__( self.recoverable_databases = RecoverableDatabasesOperations( self._client, self._config, self._serialize, self._deserialize) - self.server_connection_policies = ServerConnectionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) self.data_masking_policies = DataMaskingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize) self.data_masking_rules = DataMaskingRulesOperations( @@ -432,10 +427,6 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( self._client, self._config, self._serialize, self._deserialize) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.transparent_data_encryption_activities = TransparentDataEncryptionActivitiesOperations( - self._client, self._config, self._serialize, self._deserialize) self.server_usages = ServerUsagesOperations( self._client, self._config, self._serialize, self._deserialize) self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( @@ -628,6 +619,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.workload_groups = WorkloadGroupsOperations( self._client, self._config, self._serialize, self._deserialize) + self.transparent_data_encryptions = TransparentDataEncryptionsOperations( + self._client, self._config, self._serialize, self._deserialize) self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize) self.database_extensions = DatabaseExtensionsOperations( @@ -648,6 +641,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.usages = UsagesOperations( self._client, self._config, self._serialize, self._deserialize) + self.server_connection_policies = ServerConnectionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize) async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/__init__.py index 92dc7fbad3cb..6c977843c7cc 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/__init__.py @@ -7,7 +7,6 @@ # -------------------------------------------------------------------------- from ._recoverable_databases_operations import RecoverableDatabasesOperations -from ._server_connection_policies_operations import ServerConnectionPoliciesOperations from ._data_masking_policies_operations import DataMaskingPoliciesOperations from ._data_masking_rules_operations import DataMaskingRulesOperations from ._geo_backup_policies_operations import GeoBackupPoliciesOperations @@ -18,8 +17,6 @@ from ._service_objectives_operations import ServiceObjectivesOperations from ._elastic_pool_activities_operations import ElasticPoolActivitiesOperations from ._elastic_pool_database_activities_operations import ElasticPoolDatabaseActivitiesOperations -from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations -from ._transparent_data_encryption_activities_operations import TransparentDataEncryptionActivitiesOperations from ._server_usages_operations import ServerUsagesOperations from ._extended_database_blob_auditing_policies_operations import ExtendedDatabaseBlobAuditingPoliciesOperations from ._extended_server_blob_auditing_policies_operations import ExtendedServerBlobAuditingPoliciesOperations @@ -116,6 +113,7 @@ from ._virtual_network_rules_operations import VirtualNetworkRulesOperations from ._workload_classifiers_operations import WorkloadClassifiersOperations from ._workload_groups_operations import WorkloadGroupsOperations +from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations from ._backup_short_term_retention_policies_operations import BackupShortTermRetentionPoliciesOperations from ._database_extensions_operations import DatabaseExtensionsOperations from ._database_operations_operations import DatabaseOperationsOperations @@ -126,10 +124,10 @@ from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations from ._servers_operations import ServersOperations from ._usages_operations import UsagesOperations +from ._server_connection_policies_operations import ServerConnectionPoliciesOperations __all__ = [ 'RecoverableDatabasesOperations', - 'ServerConnectionPoliciesOperations', 'DataMaskingPoliciesOperations', 'DataMaskingRulesOperations', 'GeoBackupPoliciesOperations', @@ -140,8 +138,6 @@ 'ServiceObjectivesOperations', 'ElasticPoolActivitiesOperations', 'ElasticPoolDatabaseActivitiesOperations', - 'TransparentDataEncryptionsOperations', - 'TransparentDataEncryptionActivitiesOperations', 'ServerUsagesOperations', 'ExtendedDatabaseBlobAuditingPoliciesOperations', 'ExtendedServerBlobAuditingPoliciesOperations', @@ -238,6 +234,7 @@ 'VirtualNetworkRulesOperations', 'WorkloadClassifiersOperations', 'WorkloadGroupsOperations', + 'TransparentDataEncryptionsOperations', 'BackupShortTermRetentionPoliciesOperations', 'DatabaseExtensionsOperations', 'DatabaseOperationsOperations', @@ -248,4 +245,5 @@ 'RestorableDroppedManagedDatabasesOperations', 'ServersOperations', 'UsagesOperations', + 'ServerConnectionPoliciesOperations', ] diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py index f68bf89ad335..91146f456188 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py @@ -12,7 +12,9 @@ from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models @@ -108,7 +110,7 @@ async def get( return deserialized get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore - async def create_or_update( + async def _create_or_update_initial( self, resource_group_name: str, server_name: str, @@ -117,25 +119,6 @@ async def create_or_update( parameters: "_models.LedgerDigestUploads", **kwargs: Any ) -> Optional["_models.LedgerDigestUploads"]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :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 ledger_digest_uploads: - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :param parameters: - :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LedgerDigestUploads, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads or None - :raises: ~azure.core.exceptions.HttpResponseError - """ cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LedgerDigestUploads"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -146,7 +129,7 @@ async def create_or_update( accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), @@ -184,7 +167,90 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + parameters: "_models.LedgerDigestUploads", + **kwargs: Any + ) -> AsyncLROPoller["_models.LedgerDigestUploads"]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :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 ledger_digest_uploads: + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: + :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads + :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 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.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 LedgerDigestUploads or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploads"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LedgerDigestUploads', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore def list_by_database( self, @@ -265,7 +331,7 @@ async def get_next(next_link=None): ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads'} # type: ignore - async def disable( + async def _disable_initial( self, resource_group_name: str, server_name: str, @@ -273,23 +339,6 @@ async def disable( ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], **kwargs: Any ) -> Optional["_models.LedgerDigestUploads"]: - """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :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 ledger_digest_uploads: - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LedgerDigestUploads, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads or None - :raises: ~azure.core.exceptions.HttpResponseError - """ cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LedgerDigestUploads"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -299,7 +348,7 @@ async def disable( accept = "application/json" # Construct URL - url = self.disable.metadata['url'] # type: ignore + url = self._disable_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), @@ -333,4 +382,83 @@ async def disable( return cls(pipeline_response, deserialized, {}) return deserialized - disable.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore + _disable_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore + + async def begin_disable( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, "_models.LedgerDigestUploadsName"], + **kwargs: Any + ) -> AsyncLROPoller["_models.LedgerDigestUploads"]: + """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :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 ledger_digest_uploads: + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :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 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.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 LedgerDigestUploads or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploads"] + 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._disable_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LedgerDigestUploads', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_disable.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py index 55e5422d21dc..3bfa09c9a56b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py @@ -47,7 +47,7 @@ async def get( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], **kwargs: Any ) -> "_models.ManagedServerSecurityAlertPolicy": """Get a managed server's threat detection policy. @@ -58,7 +58,7 @@ async def get( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated + :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagedServerSecurityAlertPolicy, or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy @@ -110,7 +110,7 @@ async def _create_or_update_initial( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], parameters: "_models.ManagedServerSecurityAlertPolicy", **kwargs: Any ) -> Optional["_models.ManagedServerSecurityAlertPolicy"]: @@ -167,7 +167,7 @@ async def begin_create_or_update( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], parameters: "_models.ManagedServerSecurityAlertPolicy", **kwargs: Any ) -> AsyncLROPoller["_models.ManagedServerSecurityAlertPolicy"]: @@ -179,7 +179,7 @@ async def begin_create_or_update( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated + :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The managed server security alert policy. :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py index 9d0966e0eaf1..96c09f77bba5 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py @@ -5,13 +5,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models @@ -40,15 +43,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def create_or_update( + async def get( self, resource_group_name: str, server_name: str, connection_policy_name: Union[str, "_models.ConnectionPolicyName"], - parameters: "_models.ServerConnectionPolicy", **kwargs: Any ) -> "_models.ServerConnectionPolicy": - """Creates or updates the server's connection policy. + """Gets a server connection policy. :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. @@ -57,8 +59,6 @@ async def create_or_update( :type server_name: str :param connection_policy_name: The name of the connection policy. :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :param parameters: The required parameters for updating a secure connection policy. - :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerConnectionPolicy, or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ServerConnectionPolicy @@ -69,17 +69,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") + api_version = "2021-05-01-preview" accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -89,68 +88,48 @@ async def create_or_update( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerConnectionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + 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 response.status_code == 200: - deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) + deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore - async def get( + async def _create_or_update_initial( self, resource_group_name: str, server_name: str, connection_policy_name: Union[str, "_models.ConnectionPolicyName"], + parameters: "_models.ServerConnectionPolicy", **kwargs: Any - ) -> "_models.ServerConnectionPolicy": - """Gets the server's secure connection policy. - - :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 connection_policy_name: The name of the connection policy. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerConnectionPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerConnectionPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicy"] + ) -> Optional["_models.ServerConnectionPolicy"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerConnectionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" + api_version = "2021-05-01-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.get.metadata['url'] # type: ignore + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -160,20 +139,178 @@ async def get( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ServerConnectionPolicy') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + 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) - deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, "_models.ConnectionPolicyName"], + parameters: "_models.ServerConnectionPolicy", + **kwargs: Any + ) -> AsyncLROPoller["_models.ServerConnectionPolicy"]: + """Updates a server connection policy. + + :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 connection_policy_name: The name of the connection policy. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. + :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy + :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 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.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 ServerConnectionPolicy or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicy"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + + def list_by_server( + self, + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ServerConnectionPolicyListResult"]: + """Lists connection policy. + + :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 ServerConnectionPolicyListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-05-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ServerConnectionPolicyListResult', 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_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py index 991d0be5e5c8..8086f41e9c49 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py @@ -47,7 +47,7 @@ async def get( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], **kwargs: Any ) -> "_models.ServerSecurityAlertPolicy": """Get a server's security alert policy. @@ -58,7 +58,7 @@ async def get( :param server_name: The name of the server. :type server_name: str :param security_alert_policy_name: The name of the security alert policy. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated + :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerSecurityAlertPolicy, or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy @@ -110,7 +110,7 @@ async def _create_or_update_initial( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], parameters: "_models.ServerSecurityAlertPolicy", **kwargs: Any ) -> Optional["_models.ServerSecurityAlertPolicy"]: @@ -167,7 +167,7 @@ async def begin_create_or_update( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], parameters: "_models.ServerSecurityAlertPolicy", **kwargs: Any ) -> AsyncLROPoller["_models.ServerSecurityAlertPolicy"]: @@ -179,7 +179,7 @@ async def begin_create_or_update( :param server_name: The name of the server. :type server_name: str :param security_alert_policy_name: The name of the threat detection policy. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated + :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The server security alert policy. :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py index 2a714c6b13da..d49409322bd9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py @@ -325,7 +325,7 @@ def list_logs( sync_group_name: str, start_time: str, end_time: str, - type: Union[str, "_models.Enum77"], + type: Union[str, "_models.Enum74"], continuation_token_parameter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.SyncGroupLogListResult"]: @@ -345,7 +345,7 @@ def list_logs( :param end_time: Get logs generated before this time. :type end_time: str :param type: The types of logs to retrieve. - :type type: str or ~azure.mgmt.sql.models.Enum77 + :type type: str or ~azure.mgmt.sql.models.Enum74 :param continuation_token_parameter: The continuation token for this operation. :type continuation_token_parameter: str :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryption_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryption_activities_operations.py deleted file mode 100644 index ee95b2c2ae88..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryption_activities_operations.py +++ /dev/null @@ -1,127 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TransparentDataEncryptionActivitiesOperations: - """TransparentDataEncryptionActivitiesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.sql.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_configuration( - self, - resource_group_name: str, - server_name: str, - database_name: str, - transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], - **kwargs: Any - ) -> AsyncIterable["_models.TransparentDataEncryptionActivityListResult"]: - """Returns a database's transparent data encryption operation result. - - :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 for which the transparent data encryption - applies. - :type database_name: str - :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. - :type transparent_data_encryption_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TransparentDataEncryptionActivityListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.TransparentDataEncryptionActivityListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryptionActivityListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_configuration.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'transparentDataEncryptionName': self._serialize.url("transparent_data_encryption_name", transparent_data_encryption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('TransparentDataEncryptionActivityListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return 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_configuration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}/operationResults'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py index 8894320e1575..9da319aff594 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py @@ -5,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest @@ -40,53 +41,47 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def create_or_update( + async def get( self, resource_group_name: str, server_name: str, database_name: str, - transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], - parameters: "_models.TransparentDataEncryption", + tde_name: Union[str, "_models.TransparentDataEncryptionName"], **kwargs: Any - ) -> "_models.TransparentDataEncryption": - """Creates or updates a database's transparent data encryption configuration. + ) -> "_models.LogicalDatabaseTransparentDataEncryption": + """Gets a logical database's transparent data encryption. :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 for which setting the transparent data - encryption applies. + :param database_name: The name of the logical database for which the transparent data + encryption is defined. :type database_name: str - :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. - :type transparent_data_encryption_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The required parameters for creating or updating transparent data - encryption. - :type parameters: ~azure.mgmt.sql.models.TransparentDataEncryption + :param tde_name: The name of the transparent data encryption configuration. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName :keyword callable cls: A custom type or function that will be passed the direct response - :return: TransparentDataEncryption, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.TransparentDataEncryption + :return: LogicalDatabaseTransparentDataEncryption, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryption"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogicalDatabaseTransparentDataEncryption"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") + api_version = "2021-02-01-preview" accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'transparentDataEncryptionName': self._serialize.url("transparent_data_encryption_name", transparent_data_encryption_name, 'str'), + 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -96,74 +91,69 @@ async def create_or_update( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransparentDataEncryption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + 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 response.status_code == 200: - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryption', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}'} # type: ignore + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore - async def get( + async def create_or_update( self, resource_group_name: str, server_name: str, database_name: str, - transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], + tde_name: Union[str, "_models.TransparentDataEncryptionName"], + parameters: "_models.LogicalDatabaseTransparentDataEncryption", **kwargs: Any - ) -> "_models.TransparentDataEncryption": - """Gets a database's transparent data encryption configuration. + ) -> Optional["_models.LogicalDatabaseTransparentDataEncryption"]: + """Updates a logical database's transparent data encryption configuration. :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 for which the transparent data encryption - applies. + :param database_name: The name of the logical database for which the security alert policy is + defined. :type database_name: str - :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. - :type transparent_data_encryption_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param tde_name: The name of the transparent data encryption configuration. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. + :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption :keyword callable cls: A custom type or function that will be passed the direct response - :return: TransparentDataEncryption, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.TransparentDataEncryption + :return: LogicalDatabaseTransparentDataEncryption, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryption"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogicalDatabaseTransparentDataEncryption"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" + api_version = "2021-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.get.metadata['url'] # type: ignore + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'transparentDataEncryptionName': self._serialize.url("transparent_data_encryption_name", transparent_data_encryption_name, 'str'), + 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -173,20 +163,109 @@ async def get( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'LogicalDatabaseTransparentDataEncryption') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryption', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryption', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}'} # type: ignore + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.LogicalDatabaseTransparentDataEncryptionListResult"]: + """Gets a list of the logical database's transparent data encryption. + + :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 logical database for which the transparent data + encryption is defined. + :type database_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogicalDatabaseTransparentDataEncryptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogicalDatabaseTransparentDataEncryptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-02-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_database.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryptionListResult', 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_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption'} # type: ignore 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 db89bafe250b..fe3b3f4868a2 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 @@ -124,6 +124,8 @@ from ._models_py3 import LicenseTypeCapability from ._models_py3 import LocationCapabilities from ._models_py3 import LogSizeCapability + from ._models_py3 import LogicalDatabaseTransparentDataEncryption + from ._models_py3 import LogicalDatabaseTransparentDataEncryptionListResult from ._models_py3 import LogicalServerSecurityAlertPolicyListResult from ._models_py3 import LongTermRetentionBackup from ._models_py3 import LongTermRetentionBackupListResult @@ -265,6 +267,7 @@ from ._models_py3 import ServerCommunicationLink from ._models_py3 import ServerCommunicationLinkListResult from ._models_py3 import ServerConnectionPolicy + from ._models_py3 import ServerConnectionPolicyListResult from ._models_py3 import ServerDevOpsAuditSettingsListResult from ._models_py3 import ServerDevOpsAuditingSettings from ._models_py3 import ServerDnsAlias @@ -323,9 +326,6 @@ from ._models_py3 import TopQueries from ._models_py3 import TopQueriesListResult from ._models_py3 import TrackedResource - from ._models_py3 import TransparentDataEncryption - from ._models_py3 import TransparentDataEncryptionActivity - from ._models_py3 import TransparentDataEncryptionActivityListResult from ._models_py3 import UnlinkParameters from ._models_py3 import UpdateLongTermRetentionBackupParameters from ._models_py3 import UpdateManagedInstanceDnsServersOperation @@ -465,6 +465,8 @@ from ._models import LicenseTypeCapability # type: ignore from ._models import LocationCapabilities # type: ignore from ._models import LogSizeCapability # type: ignore + from ._models import LogicalDatabaseTransparentDataEncryption # type: ignore + from ._models import LogicalDatabaseTransparentDataEncryptionListResult # type: ignore from ._models import LogicalServerSecurityAlertPolicyListResult # type: ignore from ._models import LongTermRetentionBackup # type: ignore from ._models import LongTermRetentionBackupListResult # type: ignore @@ -606,6 +608,7 @@ from ._models import ServerCommunicationLink # type: ignore from ._models import ServerCommunicationLinkListResult # type: ignore from ._models import ServerConnectionPolicy # type: ignore + from ._models import ServerConnectionPolicyListResult # type: ignore from ._models import ServerDevOpsAuditSettingsListResult # type: ignore from ._models import ServerDevOpsAuditingSettings # type: ignore from ._models import ServerDnsAlias # type: ignore @@ -664,9 +667,6 @@ from ._models import TopQueries # type: ignore from ._models import TopQueriesListResult # type: ignore from ._models import TrackedResource # type: ignore - from ._models import TransparentDataEncryption # type: ignore - from ._models import TransparentDataEncryptionActivity # type: ignore - from ._models import TransparentDataEncryptionActivityListResult # type: ignore from ._models import UnlinkParameters # type: ignore from ._models import UpdateLongTermRetentionBackupParameters # type: ignore from ._models import UpdateManagedInstanceDnsServersOperation # type: ignore @@ -728,7 +728,7 @@ ElasticPoolLicenseType, ElasticPoolState, EncryptionProtectorName, - Enum77, + Enum74, FailoverGroupReplicationRole, GeoBackupPolicyName, GeoBackupPolicyState, @@ -789,7 +789,6 @@ SampleName, SecondaryType, SecurityAlertPolicyName, - SecurityAlertPolicyNameAutoGenerated, SecurityAlertPolicyState, SecurityAlertsPolicyState, SecurityEventType, @@ -816,10 +815,8 @@ SyncMemberState, TableTemporalType, TargetBackupStorageRedundancy, - TransparentDataEncryptionActivityStatus, TransparentDataEncryptionName, TransparentDataEncryptionState, - TransparentDataEncryptionStatus, UnitDefinitionType, UnitType, UpsertManagedServerOperationStepStatus, @@ -948,6 +945,8 @@ 'LicenseTypeCapability', 'LocationCapabilities', 'LogSizeCapability', + 'LogicalDatabaseTransparentDataEncryption', + 'LogicalDatabaseTransparentDataEncryptionListResult', 'LogicalServerSecurityAlertPolicyListResult', 'LongTermRetentionBackup', 'LongTermRetentionBackupListResult', @@ -1089,6 +1088,7 @@ 'ServerCommunicationLink', 'ServerCommunicationLinkListResult', 'ServerConnectionPolicy', + 'ServerConnectionPolicyListResult', 'ServerDevOpsAuditSettingsListResult', 'ServerDevOpsAuditingSettings', 'ServerDnsAlias', @@ -1147,9 +1147,6 @@ 'TopQueries', 'TopQueriesListResult', 'TrackedResource', - 'TransparentDataEncryption', - 'TransparentDataEncryptionActivity', - 'TransparentDataEncryptionActivityListResult', 'UnlinkParameters', 'UpdateLongTermRetentionBackupParameters', 'UpdateManagedInstanceDnsServersOperation', @@ -1209,7 +1206,7 @@ 'ElasticPoolLicenseType', 'ElasticPoolState', 'EncryptionProtectorName', - 'Enum77', + 'Enum74', 'FailoverGroupReplicationRole', 'GeoBackupPolicyName', 'GeoBackupPolicyState', @@ -1270,7 +1267,6 @@ 'SampleName', 'SecondaryType', 'SecurityAlertPolicyName', - 'SecurityAlertPolicyNameAutoGenerated', 'SecurityAlertPolicyState', 'SecurityAlertsPolicyState', 'SecurityEventType', @@ -1297,10 +1293,8 @@ 'SyncMemberState', 'TableTemporalType', 'TargetBackupStorageRedundancy', - 'TransparentDataEncryptionActivityStatus', 'TransparentDataEncryptionName', 'TransparentDataEncryptionState', - 'TransparentDataEncryptionStatus', 'UnitDefinitionType', 'UnitType', 'UpsertManagedServerOperationStepStatus', 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 5dd8f1a0f817..26785ed2b929 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 @@ -6150,6 +6150,73 @@ def __init__( self.reason = kwargs.get('reason', None) +class LogicalDatabaseTransparentDataEncryption(ProxyResource): + """A logical database transparent data encryption state. + + 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 + :param state: Specifies the state of the transparent data encryption. Possible values include: + "Enabled", "Disabled". + :type state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LogicalDatabaseTransparentDataEncryption, self).__init__(**kwargs) + self.state = kwargs.get('state', None) + + +class LogicalDatabaseTransparentDataEncryptionListResult(msrest.serialization.Model): + """A list of transparent data encryptions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of results. + :vartype value: list[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LogicalDatabaseTransparentDataEncryption]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LogicalDatabaseTransparentDataEncryptionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class LogicalServerSecurityAlertPolicyListResult(msrest.serialization.Model): """A list of the server's security alert policies. @@ -12556,7 +12623,7 @@ def __init__( class ServerConnectionPolicy(ProxyResource): - """A server secure connection policy. + """A server connection policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -12566,12 +12633,12 @@ class ServerConnectionPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar kind: Metadata used for the Azure portal experience. - :vartype kind: str :ivar location: Resource location. :vartype location: str + :ivar kind: Metadata used for the Azure portal experience. + :vartype kind: str :param connection_type: The server connection type. Possible values include: "Default", - "Proxy", "Redirect". + "Redirect", "Proxy". :type connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType """ @@ -12579,16 +12646,16 @@ class ServerConnectionPolicy(ProxyResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'kind': {'readonly': True}, 'location': {'readonly': True}, + 'kind': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, 'connection_type': {'key': 'properties.connectionType', 'type': 'str'}, } @@ -12597,11 +12664,41 @@ def __init__( **kwargs ): super(ServerConnectionPolicy, self).__init__(**kwargs) - self.kind = None self.location = None + self.kind = None self.connection_type = kwargs.get('connection_type', None) +class ServerConnectionPolicyListResult(msrest.serialization.Model): + """A list of server connection policy objects. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of results. + :vartype value: list[~azure.mgmt.sql.models.ServerConnectionPolicy] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServerConnectionPolicy]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServerConnectionPolicyListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class ServerDevOpsAuditingSettings(ProxyResource): """A server DevOps auditing settings. @@ -15097,121 +15194,6 @@ def __init__( self.next_link = None -class TransparentDataEncryption(ProxyResource): - """Represents a database transparent data encryption configuration. - - 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 location: Resource location. - :vartype location: str - :param status: The status of the database transparent data encryption. Possible values include: - "Enabled", "Disabled". - :type status: str or ~azure.mgmt.sql.models.TransparentDataEncryptionStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TransparentDataEncryption, self).__init__(**kwargs) - self.location = None - self.status = kwargs.get('status', None) - - -class TransparentDataEncryptionActivity(ProxyResource): - """Represents a database transparent data encryption Scan. - - 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 location: Resource location. - :vartype location: str - :ivar status: The status of the database. Possible values include: "Encrypting", "Decrypting". - :vartype status: str or ~azure.mgmt.sql.models.TransparentDataEncryptionActivityStatus - :ivar percent_complete: The percent complete of the transparent data encryption scan for a - database. - :vartype percent_complete: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'status': {'readonly': True}, - 'percent_complete': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(TransparentDataEncryptionActivity, self).__init__(**kwargs) - self.location = None - self.status = None - self.percent_complete = None - - -class TransparentDataEncryptionActivityListResult(msrest.serialization.Model): - """Represents the response to a list database transparent data encryption activity request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of database transparent data encryption activities. - :type value: list[~azure.mgmt.sql.models.TransparentDataEncryptionActivity] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TransparentDataEncryptionActivity]'}, - } - - def __init__( - self, - **kwargs - ): - super(TransparentDataEncryptionActivityListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - class UnlinkParameters(msrest.serialization.Model): """Represents the parameters for Unlink Replication Link request. 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 2c17ba58eb75..cccd2a155d57 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 @@ -6504,6 +6504,75 @@ def __init__( self.reason = reason +class LogicalDatabaseTransparentDataEncryption(ProxyResource): + """A logical database transparent data encryption state. + + 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 + :param state: Specifies the state of the transparent data encryption. Possible values include: + "Enabled", "Disabled". + :type state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "TransparentDataEncryptionState"]] = None, + **kwargs + ): + super(LogicalDatabaseTransparentDataEncryption, self).__init__(**kwargs) + self.state = state + + +class LogicalDatabaseTransparentDataEncryptionListResult(msrest.serialization.Model): + """A list of transparent data encryptions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of results. + :vartype value: list[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LogicalDatabaseTransparentDataEncryption]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LogicalDatabaseTransparentDataEncryptionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class LogicalServerSecurityAlertPolicyListResult(msrest.serialization.Model): """A list of the server's security alert policies. @@ -13210,7 +13279,7 @@ def __init__( class ServerConnectionPolicy(ProxyResource): - """A server secure connection policy. + """A server connection policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -13220,12 +13289,12 @@ class ServerConnectionPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar kind: Metadata used for the Azure portal experience. - :vartype kind: str :ivar location: Resource location. :vartype location: str + :ivar kind: Metadata used for the Azure portal experience. + :vartype kind: str :param connection_type: The server connection type. Possible values include: "Default", - "Proxy", "Redirect". + "Redirect", "Proxy". :type connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType """ @@ -13233,16 +13302,16 @@ class ServerConnectionPolicy(ProxyResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'kind': {'readonly': True}, 'location': {'readonly': True}, + 'kind': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, 'connection_type': {'key': 'properties.connectionType', 'type': 'str'}, } @@ -13253,11 +13322,41 @@ def __init__( **kwargs ): super(ServerConnectionPolicy, self).__init__(**kwargs) - self.kind = None self.location = None + self.kind = None self.connection_type = connection_type +class ServerConnectionPolicyListResult(msrest.serialization.Model): + """A list of server connection policy objects. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of results. + :vartype value: list[~azure.mgmt.sql.models.ServerConnectionPolicy] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServerConnectionPolicy]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServerConnectionPolicyListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class ServerDevOpsAuditingSettings(ProxyResource): """A server DevOps auditing settings. @@ -15866,125 +15965,6 @@ def __init__( self.next_link = None -class TransparentDataEncryption(ProxyResource): - """Represents a database transparent data encryption configuration. - - 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 location: Resource location. - :vartype location: str - :param status: The status of the database transparent data encryption. Possible values include: - "Enabled", "Disabled". - :type status: str or ~azure.mgmt.sql.models.TransparentDataEncryptionStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "TransparentDataEncryptionStatus"]] = None, - **kwargs - ): - super(TransparentDataEncryption, self).__init__(**kwargs) - self.location = None - self.status = status - - -class TransparentDataEncryptionActivity(ProxyResource): - """Represents a database transparent data encryption Scan. - - 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 location: Resource location. - :vartype location: str - :ivar status: The status of the database. Possible values include: "Encrypting", "Decrypting". - :vartype status: str or ~azure.mgmt.sql.models.TransparentDataEncryptionActivityStatus - :ivar percent_complete: The percent complete of the transparent data encryption scan for a - database. - :vartype percent_complete: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'status': {'readonly': True}, - 'percent_complete': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(TransparentDataEncryptionActivity, self).__init__(**kwargs) - self.location = None - self.status = None - self.percent_complete = None - - -class TransparentDataEncryptionActivityListResult(msrest.serialization.Model): - """Represents the response to a list database transparent data encryption activity request. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of database transparent data encryption activities. - :type value: list[~azure.mgmt.sql.models.TransparentDataEncryptionActivity] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TransparentDataEncryptionActivity]'}, - } - - def __init__( - self, - *, - value: List["TransparentDataEncryptionActivity"], - **kwargs - ): - super(TransparentDataEncryptionActivityListResult, self).__init__(**kwargs) - self.value = value - - class UnlinkParameters(msrest.serialization.Model): """Represents the parameters for Unlink Replication Link request. 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 a9a95e2d3790..695b5f36c6cc 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 @@ -411,7 +411,7 @@ class EncryptionProtectorName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum CURRENT = "current" -class Enum77(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Enum74(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ALL = "All" ERROR = "Error" @@ -903,10 +903,6 @@ class SecondaryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): class SecurityAlertPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - DEFAULT = "default" - -class SecurityAlertPolicyNameAutoGenerated(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - DEFAULT = "Default" class SecurityAlertPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): @@ -957,8 +953,8 @@ class ServerConnectionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """ DEFAULT = "Default" - PROXY = "Proxy" REDIRECT = "Redirect" + PROXY = "Proxy" class ServerKeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. @@ -1181,13 +1177,6 @@ class TargetBackupStorageRedundancy(with_metaclass(_CaseInsensitiveEnumMeta, str LOCAL = "Local" ZONE = "Zone" -class TransparentDataEncryptionActivityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the database. - """ - - ENCRYPTING = "Encrypting" - DECRYPTING = "Decrypting" - class TransparentDataEncryptionName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CURRENT = "current" @@ -1199,13 +1188,6 @@ class TransparentDataEncryptionState(with_metaclass(_CaseInsensitiveEnumMeta, st ENABLED = "Enabled" DISABLED = "Disabled" -class TransparentDataEncryptionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the database transparent data encryption. - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - class UnitDefinitionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ 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 92dc7fbad3cb..6c977843c7cc 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 @@ -7,7 +7,6 @@ # -------------------------------------------------------------------------- from ._recoverable_databases_operations import RecoverableDatabasesOperations -from ._server_connection_policies_operations import ServerConnectionPoliciesOperations from ._data_masking_policies_operations import DataMaskingPoliciesOperations from ._data_masking_rules_operations import DataMaskingRulesOperations from ._geo_backup_policies_operations import GeoBackupPoliciesOperations @@ -18,8 +17,6 @@ from ._service_objectives_operations import ServiceObjectivesOperations from ._elastic_pool_activities_operations import ElasticPoolActivitiesOperations from ._elastic_pool_database_activities_operations import ElasticPoolDatabaseActivitiesOperations -from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations -from ._transparent_data_encryption_activities_operations import TransparentDataEncryptionActivitiesOperations from ._server_usages_operations import ServerUsagesOperations from ._extended_database_blob_auditing_policies_operations import ExtendedDatabaseBlobAuditingPoliciesOperations from ._extended_server_blob_auditing_policies_operations import ExtendedServerBlobAuditingPoliciesOperations @@ -116,6 +113,7 @@ from ._virtual_network_rules_operations import VirtualNetworkRulesOperations from ._workload_classifiers_operations import WorkloadClassifiersOperations from ._workload_groups_operations import WorkloadGroupsOperations +from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations from ._backup_short_term_retention_policies_operations import BackupShortTermRetentionPoliciesOperations from ._database_extensions_operations import DatabaseExtensionsOperations from ._database_operations_operations import DatabaseOperationsOperations @@ -126,10 +124,10 @@ from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations from ._servers_operations import ServersOperations from ._usages_operations import UsagesOperations +from ._server_connection_policies_operations import ServerConnectionPoliciesOperations __all__ = [ 'RecoverableDatabasesOperations', - 'ServerConnectionPoliciesOperations', 'DataMaskingPoliciesOperations', 'DataMaskingRulesOperations', 'GeoBackupPoliciesOperations', @@ -140,8 +138,6 @@ 'ServiceObjectivesOperations', 'ElasticPoolActivitiesOperations', 'ElasticPoolDatabaseActivitiesOperations', - 'TransparentDataEncryptionsOperations', - 'TransparentDataEncryptionActivitiesOperations', 'ServerUsagesOperations', 'ExtendedDatabaseBlobAuditingPoliciesOperations', 'ExtendedServerBlobAuditingPoliciesOperations', @@ -238,6 +234,7 @@ 'VirtualNetworkRulesOperations', 'WorkloadClassifiersOperations', 'WorkloadGroupsOperations', + 'TransparentDataEncryptionsOperations', 'BackupShortTermRetentionPoliciesOperations', 'DatabaseExtensionsOperations', 'DatabaseOperationsOperations', @@ -248,4 +245,5 @@ 'RestorableDroppedManagedDatabasesOperations', 'ServersOperations', 'UsagesOperations', + 'ServerConnectionPoliciesOperations', ] diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py index db8e2947abab..3f74b2164b24 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py @@ -12,7 +12,9 @@ from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models @@ -113,7 +115,7 @@ def get( return deserialized get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore - def create_or_update( + def _create_or_update_initial( self, resource_group_name, # type: str server_name, # type: str @@ -123,25 +125,6 @@ def create_or_update( **kwargs # type: Any ): # type: (...) -> Optional["_models.LedgerDigestUploads"] - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :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 ledger_digest_uploads: - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :param parameters: - :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LedgerDigestUploads, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads or None - :raises: ~azure.core.exceptions.HttpResponseError - """ cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LedgerDigestUploads"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -152,7 +135,7 @@ def create_or_update( accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), @@ -190,7 +173,91 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + server_name, # type: str + database_name, # type: str + ledger_digest_uploads, # type: Union[str, "_models.LedgerDigestUploadsName"] + parameters, # type: "_models.LedgerDigestUploads" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.LedgerDigestUploads"] + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :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 ledger_digest_uploads: + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: + :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads + :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 LedgerDigestUploads or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploads"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LedgerDigestUploads', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}'} # type: ignore def list_by_database( self, @@ -272,7 +339,7 @@ def get_next(next_link=None): ) list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads'} # type: ignore - def disable( + def _disable_initial( self, resource_group_name, # type: str server_name, # type: str @@ -281,23 +348,6 @@ def disable( **kwargs # type: Any ): # type: (...) -> Optional["_models.LedgerDigestUploads"] - """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :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 ledger_digest_uploads: - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LedgerDigestUploads, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads or None - :raises: ~azure.core.exceptions.HttpResponseError - """ cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LedgerDigestUploads"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -307,7 +357,7 @@ def disable( accept = "application/json" # Construct URL - url = self.disable.metadata['url'] # type: ignore + url = self._disable_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), @@ -341,4 +391,84 @@ def disable( return cls(pipeline_response, deserialized, {}) return deserialized - disable.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore + _disable_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore + + def begin_disable( + self, + resource_group_name, # type: str + server_name, # type: str + database_name, # type: str + ledger_digest_uploads, # type: Union[str, "_models.LedgerDigestUploadsName"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.LedgerDigestUploads"] + """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :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 ledger_digest_uploads: + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :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 LedgerDigestUploads or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LedgerDigestUploads"] + 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._disable_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LedgerDigestUploads', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + 'ledgerDigestUploads': self._serialize.url("ledger_digest_uploads", ledger_digest_uploads, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_disable.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py index aef6ed163ac5..429162531975 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py @@ -51,7 +51,7 @@ def get( self, resource_group_name, # type: str managed_instance_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"] + security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] **kwargs # type: Any ): # type: (...) -> "_models.ManagedServerSecurityAlertPolicy" @@ -63,7 +63,7 @@ def get( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated + :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagedServerSecurityAlertPolicy, or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy @@ -115,7 +115,7 @@ def _create_or_update_initial( self, resource_group_name, # type: str managed_instance_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"] + security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] parameters, # type: "_models.ManagedServerSecurityAlertPolicy" **kwargs # type: Any ): @@ -173,7 +173,7 @@ def begin_create_or_update( self, resource_group_name, # type: str managed_instance_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"] + security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] parameters, # type: "_models.ManagedServerSecurityAlertPolicy" **kwargs # type: Any ): @@ -186,7 +186,7 @@ def begin_create_or_update( :param managed_instance_name: The name of the managed instance. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated + :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The managed server security alert policy. :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py index d4c447ec3073..ff6464887389 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py @@ -9,15 +9,18 @@ import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,16 +47,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def create_or_update( + def get( self, resource_group_name, # type: str server_name, # type: str connection_policy_name, # type: Union[str, "_models.ConnectionPolicyName"] - parameters, # type: "_models.ServerConnectionPolicy" **kwargs # type: Any ): # type: (...) -> "_models.ServerConnectionPolicy" - """Creates or updates the server's connection policy. + """Gets a server connection policy. :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. @@ -62,8 +64,6 @@ def create_or_update( :type server_name: str :param connection_policy_name: The name of the connection policy. :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :param parameters: The required parameters for updating a secure connection policy. - :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerConnectionPolicy, or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ServerConnectionPolicy @@ -74,17 +74,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") + api_version = "2021-05-01-preview" accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -94,69 +93,49 @@ def create_or_update( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerConnectionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + 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 response.status_code == 200: - deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) + deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore - def get( + def _create_or_update_initial( self, resource_group_name, # type: str server_name, # type: str connection_policy_name, # type: Union[str, "_models.ConnectionPolicyName"] + parameters, # type: "_models.ServerConnectionPolicy" **kwargs # type: Any ): - # type: (...) -> "_models.ServerConnectionPolicy" - """Gets the server's secure connection policy. - - :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 connection_policy_name: The name of the connection policy. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerConnectionPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerConnectionPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicy"] + # type: (...) -> Optional["_models.ServerConnectionPolicy"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerConnectionPolicy"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" + api_version = "2021-05-01-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.get.metadata['url'] # type: ignore + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -166,20 +145,180 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ServerConnectionPolicy') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + 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) - deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + server_name, # type: str + connection_policy_name, # type: Union[str, "_models.ConnectionPolicyName"] + parameters, # type: "_models.ServerConnectionPolicy" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.ServerConnectionPolicy"] + """Updates a server connection policy. + + :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 connection_policy_name: The name of the connection policy. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. + :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy + :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 ServerConnectionPolicy or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicy"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServerConnectionPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'connectionPolicyName': self._serialize.url("connection_policy_name", connection_policy_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}'} # type: ignore + + def list_by_server( + self, + resource_group_name, # type: str + server_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ServerConnectionPolicyListResult"] + """Lists connection policy. + + :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 ServerConnectionPolicyListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConnectionPolicyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-05-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ServerConnectionPolicyListResult', 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_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py index 34ca09e756df..3534bc825bf3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py @@ -51,7 +51,7 @@ def get( self, resource_group_name, # type: str server_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"] + security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] **kwargs # type: Any ): # type: (...) -> "_models.ServerSecurityAlertPolicy" @@ -63,7 +63,7 @@ def get( :param server_name: The name of the server. :type server_name: str :param security_alert_policy_name: The name of the security alert policy. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated + :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerSecurityAlertPolicy, or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy @@ -115,7 +115,7 @@ def _create_or_update_initial( self, resource_group_name, # type: str server_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"] + security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] parameters, # type: "_models.ServerSecurityAlertPolicy" **kwargs # type: Any ): @@ -173,7 +173,7 @@ def begin_create_or_update( self, resource_group_name, # type: str server_name, # type: str - security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"] + security_alert_policy_name, # type: Union[str, "_models.SecurityAlertPolicyName"] parameters, # type: "_models.ServerSecurityAlertPolicy" **kwargs # type: Any ): @@ -186,7 +186,7 @@ def begin_create_or_update( :param server_name: The name of the server. :type server_name: str :param security_alert_policy_name: The name of the threat detection policy. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated + :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The server security alert policy. :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py index a3256265690f..c3a592a01ae6 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py @@ -333,7 +333,7 @@ def list_logs( sync_group_name, # type: str start_time, # type: str end_time, # type: str - type, # type: Union[str, "_models.Enum77"] + type, # type: Union[str, "_models.Enum74"] continuation_token_parameter=None, # type: Optional[str] **kwargs # type: Any ): @@ -354,7 +354,7 @@ def list_logs( :param end_time: Get logs generated before this time. :type end_time: str :param type: The types of logs to retrieve. - :type type: str or ~azure.mgmt.sql.models.Enum77 + :type type: str or ~azure.mgmt.sql.models.Enum74 :param continuation_token_parameter: The continuation token for this operation. :type continuation_token_parameter: str :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryption_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryption_activities_operations.py deleted file mode 100644 index ec34c61315c6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryption_activities_operations.py +++ /dev/null @@ -1,132 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TransparentDataEncryptionActivitiesOperations(object): - """TransparentDataEncryptionActivitiesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.sql.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_configuration( - self, - resource_group_name, # type: str - server_name, # type: str - database_name, # type: str - transparent_data_encryption_name, # type: Union[str, "_models.TransparentDataEncryptionName"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TransparentDataEncryptionActivityListResult"] - """Returns a database's transparent data encryption operation result. - - :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 for which the transparent data encryption - applies. - :type database_name: str - :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. - :type transparent_data_encryption_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TransparentDataEncryptionActivityListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.TransparentDataEncryptionActivityListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryptionActivityListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_configuration.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'transparentDataEncryptionName': self._serialize.url("transparent_data_encryption_name", transparent_data_encryption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('TransparentDataEncryptionActivityListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return 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_configuration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}/operationResults'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py index df0ecaabf571..ff414142d1c4 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py @@ -9,6 +9,7 @@ import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.mgmt.core.exceptions import ARMErrorFormat @@ -17,7 +18,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,54 +45,48 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def create_or_update( + def get( self, resource_group_name, # type: str server_name, # type: str database_name, # type: str - transparent_data_encryption_name, # type: Union[str, "_models.TransparentDataEncryptionName"] - parameters, # type: "_models.TransparentDataEncryption" + tde_name, # type: Union[str, "_models.TransparentDataEncryptionName"] **kwargs # type: Any ): - # type: (...) -> "_models.TransparentDataEncryption" - """Creates or updates a database's transparent data encryption configuration. + # type: (...) -> "_models.LogicalDatabaseTransparentDataEncryption" + """Gets a logical database's transparent data encryption. :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 for which setting the transparent data - encryption applies. + :param database_name: The name of the logical database for which the transparent data + encryption is defined. :type database_name: str - :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. - :type transparent_data_encryption_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The required parameters for creating or updating transparent data - encryption. - :type parameters: ~azure.mgmt.sql.models.TransparentDataEncryption + :param tde_name: The name of the transparent data encryption configuration. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName :keyword callable cls: A custom type or function that will be passed the direct response - :return: TransparentDataEncryption, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.TransparentDataEncryption + :return: LogicalDatabaseTransparentDataEncryption, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryption"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogicalDatabaseTransparentDataEncryption"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - content_type = kwargs.pop("content_type", "application/json") + api_version = "2021-02-01-preview" accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'transparentDataEncryptionName': self._serialize.url("transparent_data_encryption_name", transparent_data_encryption_name, 'str'), + 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -101,75 +96,70 @@ def create_or_update( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransparentDataEncryption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + 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 response.status_code == 200: - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryption', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}'} # type: ignore + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore - def get( + def create_or_update( self, resource_group_name, # type: str server_name, # type: str database_name, # type: str - transparent_data_encryption_name, # type: Union[str, "_models.TransparentDataEncryptionName"] + tde_name, # type: Union[str, "_models.TransparentDataEncryptionName"] + parameters, # type: "_models.LogicalDatabaseTransparentDataEncryption" **kwargs # type: Any ): - # type: (...) -> "_models.TransparentDataEncryption" - """Gets a database's transparent data encryption configuration. + # type: (...) -> Optional["_models.LogicalDatabaseTransparentDataEncryption"] + """Updates a logical database's transparent data encryption configuration. :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 for which the transparent data encryption - applies. + :param database_name: The name of the logical database for which the security alert policy is + defined. :type database_name: str - :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. - :type transparent_data_encryption_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param tde_name: The name of the transparent data encryption configuration. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. + :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption :keyword callable cls: A custom type or function that will be passed the direct response - :return: TransparentDataEncryption, or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.TransparentDataEncryption + :return: LogicalDatabaseTransparentDataEncryption, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryption"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogicalDatabaseTransparentDataEncryption"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" + api_version = "2021-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.get.metadata['url'] # type: ignore + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serverName': self._serialize.url("server_name", server_name, 'str'), 'databaseName': self._serialize.url("database_name", database_name, 'str'), - 'transparentDataEncryptionName': self._serialize.url("transparent_data_encryption_name", transparent_data_encryption_name, 'str'), + 'tdeName': self._serialize.url("tde_name", tde_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -179,20 +169,110 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'LogicalDatabaseTransparentDataEncryption') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryption', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryption', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}'} # type: ignore + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}'} # type: ignore + + def list_by_database( + self, + resource_group_name, # type: str + server_name, # type: str + database_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.LogicalDatabaseTransparentDataEncryptionListResult"] + """Gets a list of the logical database's transparent data encryption. + + :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 logical database for which the transparent data + encryption is defined. + :type database_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogicalDatabaseTransparentDataEncryptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogicalDatabaseTransparentDataEncryptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-02-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_database.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('LogicalDatabaseTransparentDataEncryptionListResult', 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_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption'} # type: ignore