diff --git a/sdk/sql/azure-mgmt-sql/_meta.json b/sdk/sql/azure-mgmt-sql/_meta.json index 7d5073a6c099..b7630dee5e06 100644 --- a/sdk/sql/azure-mgmt-sql/_meta.json +++ b/sdk/sql/azure-mgmt-sql/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "b9b91929c304f8fb44002267b6c98d9fb9dde014", + "commit": "3b1e32e79d02ff5b40265a815e56de2774ee7b2f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/sql/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/sql/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/sql/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py index a6f3006ba5bc..90336b46b29c 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 @@ -16,7 +16,7 @@ from . import models from ._configuration import SqlManagementClientConfiguration -from .operations import BackupShortTermRetentionPoliciesOperations, CapabilitiesOperations, DataMaskingPoliciesOperations, DataMaskingRulesOperations, DataWarehouseUserActivitiesOperations, DatabaseAdvancedThreatProtectionSettingsOperations, DatabaseAdvisorsOperations, DatabaseAutomaticTuningOperations, DatabaseBlobAuditingPoliciesOperations, DatabaseColumnsOperations, DatabaseExtensionsOperations, DatabaseOperationsOperations, DatabaseRecommendedActionsOperations, DatabaseSchemasOperations, DatabaseSecurityAlertPoliciesOperations, DatabaseTablesOperations, DatabaseUsagesOperations, DatabaseVulnerabilityAssessmentRuleBaselinesOperations, DatabaseVulnerabilityAssessmentScansOperations, DatabaseVulnerabilityAssessmentsOperations, DatabasesOperations, DeletedServersOperations, DistributedAvailabilityGroupsOperations, ElasticPoolActivitiesOperations, ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, EndpointCertificatesOperations, ExtendedDatabaseBlobAuditingPoliciesOperations, ExtendedServerBlobAuditingPoliciesOperations, FailoverGroupsOperations, FirewallRulesOperations, GeoBackupPoliciesOperations, IPv6FirewallRulesOperations, InstanceFailoverGroupsOperations, InstancePoolsOperations, JobAgentsOperations, JobCredentialsOperations, JobExecutionsOperations, JobStepExecutionsOperations, JobStepsOperations, JobTargetExecutionsOperations, JobTargetGroupsOperations, JobVersionsOperations, JobsOperations, LedgerDigestUploadsOperations, LongTermRetentionBackupsOperations, LongTermRetentionManagedInstanceBackupsOperations, LongTermRetentionPoliciesOperations, MaintenanceWindowOptionsOperations, MaintenanceWindowsOperations, ManagedBackupShortTermRetentionPoliciesOperations, ManagedDatabaseColumnsOperations, ManagedDatabaseQueriesOperations, ManagedDatabaseRecommendedSensitivityLabelsOperations, ManagedDatabaseRestoreDetailsOperations, ManagedDatabaseSchemasOperations, ManagedDatabaseSecurityAlertPoliciesOperations, ManagedDatabaseSecurityEventsOperations, ManagedDatabaseSensitivityLabelsOperations, ManagedDatabaseTablesOperations, ManagedDatabaseTransparentDataEncryptionOperations, ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations, ManagedDatabaseVulnerabilityAssessmentScansOperations, ManagedDatabaseVulnerabilityAssessmentsOperations, ManagedDatabasesOperations, ManagedInstanceAdministratorsOperations, ManagedInstanceAzureADOnlyAuthenticationsOperations, ManagedInstanceEncryptionProtectorsOperations, ManagedInstanceKeysOperations, ManagedInstanceLongTermRetentionPoliciesOperations, ManagedInstanceOperationsOperations, ManagedInstancePrivateEndpointConnectionsOperations, ManagedInstancePrivateLinkResourcesOperations, ManagedInstanceTdeCertificatesOperations, ManagedInstanceVulnerabilityAssessmentsOperations, ManagedInstancesOperations, ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RecommendedSensitivityLabelsOperations, RecoverableDatabasesOperations, RecoverableManagedDatabasesOperations, ReplicationLinksOperations, RestorableDroppedDatabasesOperations, RestorableDroppedManagedDatabasesOperations, RestorePointsOperations, SensitivityLabelsOperations, ServerAdvancedThreatProtectionSettingsOperations, ServerAdvisorsOperations, ServerAutomaticTuningOperations, ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, ServerCommunicationLinksOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, ServerDnsAliasesOperations, ServerKeysOperations, ServerOperationsOperations, ServerSecurityAlertPoliciesOperations, ServerTrustCertificatesOperations, ServerTrustGroupsOperations, ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, ServiceObjectivesOperations, SqlAgentOperations, SubscriptionUsagesOperations, SyncAgentsOperations, SyncGroupsOperations, SyncMembersOperations, TdeCertificatesOperations, TimeZonesOperations, TransparentDataEncryptionsOperations, UsagesOperations, VirtualClustersOperations, VirtualNetworkRulesOperations, WorkloadClassifiersOperations, WorkloadGroupsOperations +from .operations import BackupShortTermRetentionPoliciesOperations, CapabilitiesOperations, DataMaskingPoliciesOperations, DataMaskingRulesOperations, DataWarehouseUserActivitiesOperations, DatabaseAdvancedThreatProtectionSettingsOperations, DatabaseAdvisorsOperations, DatabaseAutomaticTuningOperations, DatabaseBlobAuditingPoliciesOperations, DatabaseColumnsOperations, DatabaseExtensionsOperations, DatabaseOperationsOperations, DatabaseRecommendedActionsOperations, DatabaseSchemasOperations, DatabaseSecurityAlertPoliciesOperations, DatabaseTablesOperations, DatabaseUsagesOperations, DatabaseVulnerabilityAssessmentRuleBaselinesOperations, DatabaseVulnerabilityAssessmentScansOperations, DatabaseVulnerabilityAssessmentsOperations, DatabasesOperations, DeletedServersOperations, DistributedAvailabilityGroupsOperations, ElasticPoolActivitiesOperations, ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, EndpointCertificatesOperations, ExtendedDatabaseBlobAuditingPoliciesOperations, ExtendedServerBlobAuditingPoliciesOperations, FailoverGroupsOperations, FirewallRulesOperations, GeoBackupPoliciesOperations, IPv6FirewallRulesOperations, InstanceFailoverGroupsOperations, InstancePoolsOperations, JobAgentsOperations, JobCredentialsOperations, JobExecutionsOperations, JobStepExecutionsOperations, JobStepsOperations, JobTargetExecutionsOperations, JobTargetGroupsOperations, JobVersionsOperations, JobsOperations, LedgerDigestUploadsOperations, LongTermRetentionBackupsOperations, LongTermRetentionManagedInstanceBackupsOperations, LongTermRetentionPoliciesOperations, MaintenanceWindowOptionsOperations, MaintenanceWindowsOperations, ManagedBackupShortTermRetentionPoliciesOperations, ManagedDatabaseAdvancedThreatProtectionSettingsOperations, ManagedDatabaseColumnsOperations, ManagedDatabaseQueriesOperations, ManagedDatabaseRecommendedSensitivityLabelsOperations, ManagedDatabaseRestoreDetailsOperations, ManagedDatabaseSchemasOperations, ManagedDatabaseSecurityAlertPoliciesOperations, ManagedDatabaseSecurityEventsOperations, ManagedDatabaseSensitivityLabelsOperations, ManagedDatabaseTablesOperations, ManagedDatabaseTransparentDataEncryptionOperations, ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations, ManagedDatabaseVulnerabilityAssessmentScansOperations, ManagedDatabaseVulnerabilityAssessmentsOperations, ManagedDatabasesOperations, ManagedInstanceAdministratorsOperations, ManagedInstanceAdvancedThreatProtectionSettingsOperations, ManagedInstanceAzureADOnlyAuthenticationsOperations, ManagedInstanceDtcsOperations, ManagedInstanceEncryptionProtectorsOperations, ManagedInstanceKeysOperations, ManagedInstanceLongTermRetentionPoliciesOperations, ManagedInstanceOperationsOperations, ManagedInstancePrivateEndpointConnectionsOperations, ManagedInstancePrivateLinkResourcesOperations, ManagedInstanceTdeCertificatesOperations, ManagedInstanceVulnerabilityAssessmentsOperations, ManagedInstancesOperations, ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RecommendedSensitivityLabelsOperations, RecoverableDatabasesOperations, RecoverableManagedDatabasesOperations, ReplicationLinksOperations, RestorableDroppedDatabasesOperations, RestorableDroppedManagedDatabasesOperations, RestorePointsOperations, SensitivityLabelsOperations, ServerAdvancedThreatProtectionSettingsOperations, ServerAdvisorsOperations, ServerAutomaticTuningOperations, ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, ServerCommunicationLinksOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, ServerDnsAliasesOperations, ServerKeysOperations, ServerOperationsOperations, ServerSecurityAlertPoliciesOperations, ServerTrustCertificatesOperations, ServerTrustGroupsOperations, ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, ServiceObjectivesOperations, SqlAgentOperations, SubscriptionUsagesOperations, SyncAgentsOperations, SyncGroupsOperations, SyncMembersOperations, TdeCertificatesOperations, TimeZonesOperations, TransparentDataEncryptionsOperations, UsagesOperations, VirtualClustersOperations, VirtualNetworkRulesOperations, WorkloadClassifiersOperations, WorkloadGroupsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -357,6 +357,16 @@ class SqlManagementClient: # pylint: disable=too-many-instance-attributes :ivar managed_server_dns_aliases: ManagedServerDnsAliasesOperations operations :vartype managed_server_dns_aliases: azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations + :ivar managed_instance_dtcs: ManagedInstanceDtcsOperations operations + :vartype managed_instance_dtcs: azure.mgmt.sql.operations.ManagedInstanceDtcsOperations + :ivar managed_database_advanced_threat_protection_settings: + ManagedDatabaseAdvancedThreatProtectionSettingsOperations operations + :vartype managed_database_advanced_threat_protection_settings: + azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations + :ivar managed_instance_advanced_threat_protection_settings: + ManagedInstanceAdvancedThreatProtectionSettingsOperations operations + :vartype managed_instance_advanced_threat_protection_settings: + azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations :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. @@ -756,6 +766,15 @@ def __init__( self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_database_advanced_threat_protection_settings = ManagedDatabaseAdvancedThreatProtectionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_instance_advanced_threat_protection_settings = ManagedInstanceAdvancedThreatProtectionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 0cc2e55e6243..c78e629b6f08 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0b3" +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 7661fedb80a8..60f41b4174f7 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 @@ -16,7 +16,7 @@ from .. import models from ._configuration import SqlManagementClientConfiguration -from .operations import BackupShortTermRetentionPoliciesOperations, CapabilitiesOperations, DataMaskingPoliciesOperations, DataMaskingRulesOperations, DataWarehouseUserActivitiesOperations, DatabaseAdvancedThreatProtectionSettingsOperations, DatabaseAdvisorsOperations, DatabaseAutomaticTuningOperations, DatabaseBlobAuditingPoliciesOperations, DatabaseColumnsOperations, DatabaseExtensionsOperations, DatabaseOperationsOperations, DatabaseRecommendedActionsOperations, DatabaseSchemasOperations, DatabaseSecurityAlertPoliciesOperations, DatabaseTablesOperations, DatabaseUsagesOperations, DatabaseVulnerabilityAssessmentRuleBaselinesOperations, DatabaseVulnerabilityAssessmentScansOperations, DatabaseVulnerabilityAssessmentsOperations, DatabasesOperations, DeletedServersOperations, DistributedAvailabilityGroupsOperations, ElasticPoolActivitiesOperations, ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, EndpointCertificatesOperations, ExtendedDatabaseBlobAuditingPoliciesOperations, ExtendedServerBlobAuditingPoliciesOperations, FailoverGroupsOperations, FirewallRulesOperations, GeoBackupPoliciesOperations, IPv6FirewallRulesOperations, InstanceFailoverGroupsOperations, InstancePoolsOperations, JobAgentsOperations, JobCredentialsOperations, JobExecutionsOperations, JobStepExecutionsOperations, JobStepsOperations, JobTargetExecutionsOperations, JobTargetGroupsOperations, JobVersionsOperations, JobsOperations, LedgerDigestUploadsOperations, LongTermRetentionBackupsOperations, LongTermRetentionManagedInstanceBackupsOperations, LongTermRetentionPoliciesOperations, MaintenanceWindowOptionsOperations, MaintenanceWindowsOperations, ManagedBackupShortTermRetentionPoliciesOperations, ManagedDatabaseColumnsOperations, ManagedDatabaseQueriesOperations, ManagedDatabaseRecommendedSensitivityLabelsOperations, ManagedDatabaseRestoreDetailsOperations, ManagedDatabaseSchemasOperations, ManagedDatabaseSecurityAlertPoliciesOperations, ManagedDatabaseSecurityEventsOperations, ManagedDatabaseSensitivityLabelsOperations, ManagedDatabaseTablesOperations, ManagedDatabaseTransparentDataEncryptionOperations, ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations, ManagedDatabaseVulnerabilityAssessmentScansOperations, ManagedDatabaseVulnerabilityAssessmentsOperations, ManagedDatabasesOperations, ManagedInstanceAdministratorsOperations, ManagedInstanceAzureADOnlyAuthenticationsOperations, ManagedInstanceEncryptionProtectorsOperations, ManagedInstanceKeysOperations, ManagedInstanceLongTermRetentionPoliciesOperations, ManagedInstanceOperationsOperations, ManagedInstancePrivateEndpointConnectionsOperations, ManagedInstancePrivateLinkResourcesOperations, ManagedInstanceTdeCertificatesOperations, ManagedInstanceVulnerabilityAssessmentsOperations, ManagedInstancesOperations, ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RecommendedSensitivityLabelsOperations, RecoverableDatabasesOperations, RecoverableManagedDatabasesOperations, ReplicationLinksOperations, RestorableDroppedDatabasesOperations, RestorableDroppedManagedDatabasesOperations, RestorePointsOperations, SensitivityLabelsOperations, ServerAdvancedThreatProtectionSettingsOperations, ServerAdvisorsOperations, ServerAutomaticTuningOperations, ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, ServerCommunicationLinksOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, ServerDnsAliasesOperations, ServerKeysOperations, ServerOperationsOperations, ServerSecurityAlertPoliciesOperations, ServerTrustCertificatesOperations, ServerTrustGroupsOperations, ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, ServiceObjectivesOperations, SqlAgentOperations, SubscriptionUsagesOperations, SyncAgentsOperations, SyncGroupsOperations, SyncMembersOperations, TdeCertificatesOperations, TimeZonesOperations, TransparentDataEncryptionsOperations, UsagesOperations, VirtualClustersOperations, VirtualNetworkRulesOperations, WorkloadClassifiersOperations, WorkloadGroupsOperations +from .operations import BackupShortTermRetentionPoliciesOperations, CapabilitiesOperations, DataMaskingPoliciesOperations, DataMaskingRulesOperations, DataWarehouseUserActivitiesOperations, DatabaseAdvancedThreatProtectionSettingsOperations, DatabaseAdvisorsOperations, DatabaseAutomaticTuningOperations, DatabaseBlobAuditingPoliciesOperations, DatabaseColumnsOperations, DatabaseExtensionsOperations, DatabaseOperationsOperations, DatabaseRecommendedActionsOperations, DatabaseSchemasOperations, DatabaseSecurityAlertPoliciesOperations, DatabaseTablesOperations, DatabaseUsagesOperations, DatabaseVulnerabilityAssessmentRuleBaselinesOperations, DatabaseVulnerabilityAssessmentScansOperations, DatabaseVulnerabilityAssessmentsOperations, DatabasesOperations, DeletedServersOperations, DistributedAvailabilityGroupsOperations, ElasticPoolActivitiesOperations, ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, EndpointCertificatesOperations, ExtendedDatabaseBlobAuditingPoliciesOperations, ExtendedServerBlobAuditingPoliciesOperations, FailoverGroupsOperations, FirewallRulesOperations, GeoBackupPoliciesOperations, IPv6FirewallRulesOperations, InstanceFailoverGroupsOperations, InstancePoolsOperations, JobAgentsOperations, JobCredentialsOperations, JobExecutionsOperations, JobStepExecutionsOperations, JobStepsOperations, JobTargetExecutionsOperations, JobTargetGroupsOperations, JobVersionsOperations, JobsOperations, LedgerDigestUploadsOperations, LongTermRetentionBackupsOperations, LongTermRetentionManagedInstanceBackupsOperations, LongTermRetentionPoliciesOperations, MaintenanceWindowOptionsOperations, MaintenanceWindowsOperations, ManagedBackupShortTermRetentionPoliciesOperations, ManagedDatabaseAdvancedThreatProtectionSettingsOperations, ManagedDatabaseColumnsOperations, ManagedDatabaseQueriesOperations, ManagedDatabaseRecommendedSensitivityLabelsOperations, ManagedDatabaseRestoreDetailsOperations, ManagedDatabaseSchemasOperations, ManagedDatabaseSecurityAlertPoliciesOperations, ManagedDatabaseSecurityEventsOperations, ManagedDatabaseSensitivityLabelsOperations, ManagedDatabaseTablesOperations, ManagedDatabaseTransparentDataEncryptionOperations, ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations, ManagedDatabaseVulnerabilityAssessmentScansOperations, ManagedDatabaseVulnerabilityAssessmentsOperations, ManagedDatabasesOperations, ManagedInstanceAdministratorsOperations, ManagedInstanceAdvancedThreatProtectionSettingsOperations, ManagedInstanceAzureADOnlyAuthenticationsOperations, ManagedInstanceDtcsOperations, ManagedInstanceEncryptionProtectorsOperations, ManagedInstanceKeysOperations, ManagedInstanceLongTermRetentionPoliciesOperations, ManagedInstanceOperationsOperations, ManagedInstancePrivateEndpointConnectionsOperations, ManagedInstancePrivateLinkResourcesOperations, ManagedInstanceTdeCertificatesOperations, ManagedInstanceVulnerabilityAssessmentsOperations, ManagedInstancesOperations, ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RecommendedSensitivityLabelsOperations, RecoverableDatabasesOperations, RecoverableManagedDatabasesOperations, ReplicationLinksOperations, RestorableDroppedDatabasesOperations, RestorableDroppedManagedDatabasesOperations, RestorePointsOperations, SensitivityLabelsOperations, ServerAdvancedThreatProtectionSettingsOperations, ServerAdvisorsOperations, ServerAutomaticTuningOperations, ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, ServerCommunicationLinksOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, ServerDnsAliasesOperations, ServerKeysOperations, ServerOperationsOperations, ServerSecurityAlertPoliciesOperations, ServerTrustCertificatesOperations, ServerTrustGroupsOperations, ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, ServiceObjectivesOperations, SqlAgentOperations, SubscriptionUsagesOperations, SyncAgentsOperations, SyncGroupsOperations, SyncMembersOperations, TdeCertificatesOperations, TimeZonesOperations, TransparentDataEncryptionsOperations, UsagesOperations, VirtualClustersOperations, VirtualNetworkRulesOperations, WorkloadClassifiersOperations, WorkloadGroupsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -363,6 +363,16 @@ class SqlManagementClient: # pylint: disable=too-many-instance-attributes :ivar managed_server_dns_aliases: ManagedServerDnsAliasesOperations operations :vartype managed_server_dns_aliases: azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations + :ivar managed_instance_dtcs: ManagedInstanceDtcsOperations operations + :vartype managed_instance_dtcs: azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations + :ivar managed_database_advanced_threat_protection_settings: + ManagedDatabaseAdvancedThreatProtectionSettingsOperations operations + :vartype managed_database_advanced_threat_protection_settings: + azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations + :ivar managed_instance_advanced_threat_protection_settings: + ManagedInstanceAdvancedThreatProtectionSettingsOperations operations + :vartype managed_instance_advanced_threat_protection_settings: + azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations :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. @@ -762,6 +772,15 @@ def __init__( self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_database_advanced_threat_protection_settings = ManagedDatabaseAdvancedThreatProtectionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_instance_advanced_threat_protection_settings = ManagedInstanceAdvancedThreatProtectionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 3848df9ec3ed..37a7f5c2a8b0 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 @@ -131,6 +131,9 @@ from ._database_advanced_threat_protection_settings_operations import DatabaseAdvancedThreatProtectionSettingsOperations from ._server_advanced_threat_protection_settings_operations import ServerAdvancedThreatProtectionSettingsOperations from ._managed_server_dns_aliases_operations import ManagedServerDnsAliasesOperations +from ._managed_instance_dtcs_operations import ManagedInstanceDtcsOperations +from ._managed_database_advanced_threat_protection_settings_operations import ManagedDatabaseAdvancedThreatProtectionSettingsOperations +from ._managed_instance_advanced_threat_protection_settings_operations import ManagedInstanceAdvancedThreatProtectionSettingsOperations from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import @@ -261,6 +264,9 @@ 'DatabaseAdvancedThreatProtectionSettingsOperations', 'ServerAdvancedThreatProtectionSettingsOperations', 'ManagedServerDnsAliasesOperations', + 'ManagedInstanceDtcsOperations', + 'ManagedDatabaseAdvancedThreatProtectionSettingsOperations', + 'ManagedInstanceAdvancedThreatProtectionSettingsOperations', ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py new file mode 100644 index 000000000000..0f66dc4814c4 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py @@ -0,0 +1,307 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union + +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._managed_database_advanced_threat_protection_settings_operations import build_create_or_update_request, build_get_request, build_list_by_database_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagedDatabaseAdvancedThreatProtectionSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_advanced_threat_protection_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ManagedDatabaseAdvancedThreatProtectionListResult]: + """Gets a list of managed database's Advanced Threat Protection states. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param database_name: The name of the database. + :type database_name: str + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedDatabaseAdvancedThreatProtectionListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedDatabaseAdvancedThreatProtectionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ManagedDatabaseAdvancedThreatProtectionListResult", 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( # pylint: disable=protected-access + 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/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Gets a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param database_name: The name of the database. + :type database_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedDatabaseAdvancedThreatProtection, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] + + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + + deserialized = self._deserialize('ManagedDatabaseAdvancedThreatProtection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + parameters: _models.ManagedDatabaseAdvancedThreatProtection, + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param database_name: The name of the database. + :type database_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedDatabaseAdvancedThreatProtection, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] + + _json = self._serialize.body(parameters, 'ManagedDatabaseAdvancedThreatProtection') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('ManagedDatabaseAdvancedThreatProtection', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedDatabaseAdvancedThreatProtection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py new file mode 100644 index 000000000000..cedc3978b806 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py @@ -0,0 +1,365 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._managed_instance_advanced_threat_protection_settings_operations import build_create_or_update_request_initial, build_get_request, build_list_by_instance_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagedInstanceAdvancedThreatProtectionSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_advanced_threat_protection_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_instance( + self, + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ManagedInstanceAdvancedThreatProtectionListResult]: + """Get the managed instance's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedInstanceAdvancedThreatProtectionListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceAdvancedThreatProtectionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_instance.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ManagedInstanceAdvancedThreatProtectionListResult", 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( # pylint: disable=protected-access + 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_instance.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + **kwargs: Any + ) -> _models.ManagedInstanceAdvancedThreatProtection: + """Get a managed instance's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedInstanceAdvancedThreatProtection, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceAdvancedThreatProtection] + + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + + deserialized = self._deserialize('ManagedInstanceAdvancedThreatProtection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + parameters: _models.ManagedInstanceAdvancedThreatProtection, + **kwargs: Any + ) -> Optional[_models.ManagedInstanceAdvancedThreatProtection]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ManagedInstanceAdvancedThreatProtection]] + + _json = self._serialize.body(parameters, 'ManagedInstanceAdvancedThreatProtection') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagedInstanceAdvancedThreatProtection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + parameters: _models.ManagedInstanceAdvancedThreatProtection, + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be 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 + ManagedInstanceAdvancedThreatProtection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceAdvancedThreatProtection] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ManagedInstanceAdvancedThreatProtection', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, 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 + ) + 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/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py new file mode 100644 index 000000000000..f59d72a8a6f3 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py @@ -0,0 +1,360 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._managed_instance_dtcs_operations import build_create_or_update_request_initial, build_get_request, build_list_by_managed_instance_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagedInstanceDtcsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_dtcs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_managed_instance( + self, + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ManagedInstanceDtcListResult]: + """Gets a list of managed instance DTC settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedInstanceDtcListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceDtcListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceDtcListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_managed_instance.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ManagedInstanceDtcListResult", 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( # pylint: disable=protected-access + 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_managed_instance.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, "_models.DtcName"], + **kwargs: Any + ) -> _models.ManagedInstanceDtc: + """Gets managed instance DTC settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedInstanceDtc, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.ManagedInstanceDtc + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceDtc] + + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + + deserialized = self._deserialize('ManagedInstanceDtc', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, "_models.DtcName"], + parameters: _models.ManagedInstanceDtc, + **kwargs: Any + ) -> _models.ManagedInstanceDtc: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceDtc] + + _json = self._serialize.body(parameters, 'ManagedInstanceDtc') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + + deserialized = self._deserialize('ManagedInstanceDtc', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, "_models.DtcName"], + parameters: _models.ManagedInstanceDtc, + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be 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 ManagedInstanceDtc or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceDtc] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ManagedInstanceDtc', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, 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 + ) + 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/managedInstances/{managedInstanceName}/dtc/{dtcName}"} # 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 2f1e6cc8375a..4e156433b75f 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 @@ -149,6 +149,8 @@ from ._models_py3 import ManagedBackupShortTermRetentionPolicy from ._models_py3 import ManagedBackupShortTermRetentionPolicyListResult from ._models_py3 import ManagedDatabase +from ._models_py3 import ManagedDatabaseAdvancedThreatProtection +from ._models_py3 import ManagedDatabaseAdvancedThreatProtectionListResult from ._models_py3 import ManagedDatabaseListResult from ._models_py3 import ManagedDatabaseRestoreDetailsResult from ._models_py3 import ManagedDatabaseSecurityAlertPolicy @@ -157,8 +159,14 @@ from ._models_py3 import ManagedInstance from ._models_py3 import ManagedInstanceAdministrator from ._models_py3 import ManagedInstanceAdministratorListResult +from ._models_py3 import ManagedInstanceAdvancedThreatProtection +from ._models_py3 import ManagedInstanceAdvancedThreatProtectionListResult from ._models_py3 import ManagedInstanceAzureADOnlyAuthListResult from ._models_py3 import ManagedInstanceAzureADOnlyAuthentication +from ._models_py3 import ManagedInstanceDtc +from ._models_py3 import ManagedInstanceDtcListResult +from ._models_py3 import ManagedInstanceDtcSecuritySettings +from ._models_py3 import ManagedInstanceDtcTransactionManagerCommunicationSettings from ._models_py3 import ManagedInstanceEditionCapability from ._models_py3 import ManagedInstanceEncryptionProtector from ._models_py3 import ManagedInstanceEncryptionProtectorListResult @@ -402,6 +410,7 @@ DayOfWeek, DiffBackupIntervalInHours, DnsRefreshConfigurationPropertiesStatus, + DtcName, ElasticPoolLicenseType, ElasticPoolState, EncryptionProtectorName, @@ -648,6 +657,8 @@ 'ManagedBackupShortTermRetentionPolicy', 'ManagedBackupShortTermRetentionPolicyListResult', 'ManagedDatabase', + 'ManagedDatabaseAdvancedThreatProtection', + 'ManagedDatabaseAdvancedThreatProtectionListResult', 'ManagedDatabaseListResult', 'ManagedDatabaseRestoreDetailsResult', 'ManagedDatabaseSecurityAlertPolicy', @@ -656,8 +667,14 @@ 'ManagedInstance', 'ManagedInstanceAdministrator', 'ManagedInstanceAdministratorListResult', + 'ManagedInstanceAdvancedThreatProtection', + 'ManagedInstanceAdvancedThreatProtectionListResult', 'ManagedInstanceAzureADOnlyAuthListResult', 'ManagedInstanceAzureADOnlyAuthentication', + 'ManagedInstanceDtc', + 'ManagedInstanceDtcListResult', + 'ManagedInstanceDtcSecuritySettings', + 'ManagedInstanceDtcTransactionManagerCommunicationSettings', 'ManagedInstanceEditionCapability', 'ManagedInstanceEncryptionProtector', 'ManagedInstanceEncryptionProtectorListResult', @@ -898,6 +915,7 @@ 'DayOfWeek', 'DiffBackupIntervalInHours', 'DnsRefreshConfigurationPropertiesStatus', + 'DtcName', 'ElasticPoolLicenseType', 'ElasticPoolState', 'EncryptionProtectorName', 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 c0a21a0ef0b2..a0a199b4585f 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 @@ -9384,6 +9384,94 @@ def __init__( self.last_backup_name = last_backup_name +class ManagedDatabaseAdvancedThreatProtection(ProxyResource): + """A managed database Advanced Threat Protection. + + 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 system_data: SystemData of AdvancedThreatProtectionResource. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar state: Specifies the state of the Advanced Threat Protection, whether it is enabled or + disabled or a state has not been applied yet on the specific database or server. Known values + are: "New", "Enabled", "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState + :ivar creation_time: Specifies the UTC creation time of the policy. + :vartype creation_time: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'creation_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.AdvancedThreatProtectionState"]] = None, + **kwargs + ): + """ + :keyword state: Specifies the state of the Advanced Threat Protection, whether it is enabled or + disabled or a state has not been applied yet on the specific database or server. Known values + are: "New", "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState + """ + super(ManagedDatabaseAdvancedThreatProtection, self).__init__(**kwargs) + self.system_data = None + self.state = state + self.creation_time = None + + +class ManagedDatabaseAdvancedThreatProtectionListResult(msrest.serialization.Model): + """A list of the managed database's Advanced Threat Protection settings. + + 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.ManagedDatabaseAdvancedThreatProtection] + :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': '[ManagedDatabaseAdvancedThreatProtection]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ManagedDatabaseAdvancedThreatProtectionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class ManagedDatabaseListResult(msrest.serialization.Model): """A list of managed databases. @@ -10231,6 +10319,94 @@ def __init__( self.next_link = None +class ManagedInstanceAdvancedThreatProtection(ProxyResource): + """A managed instance Advanced Threat Protection. + + 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 system_data: SystemData of AdvancedThreatProtectionResource. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar state: Specifies the state of the Advanced Threat Protection, whether it is enabled or + disabled or a state has not been applied yet on the specific database or server. Known values + are: "New", "Enabled", "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState + :ivar creation_time: Specifies the UTC creation time of the policy. + :vartype creation_time: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'creation_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.AdvancedThreatProtectionState"]] = None, + **kwargs + ): + """ + :keyword state: Specifies the state of the Advanced Threat Protection, whether it is enabled or + disabled or a state has not been applied yet on the specific database or server. Known values + are: "New", "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState + """ + super(ManagedInstanceAdvancedThreatProtection, self).__init__(**kwargs) + self.system_data = None + self.state = state + self.creation_time = None + + +class ManagedInstanceAdvancedThreatProtectionListResult(msrest.serialization.Model): + """A list of the managed instance's Advanced Threat Protection settings. + + 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.ManagedInstanceAdvancedThreatProtection] + :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': '[ManagedInstanceAdvancedThreatProtection]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ManagedInstanceAdvancedThreatProtectionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class ManagedInstanceAzureADOnlyAuthentication(ProxyResource): """Azure Active Directory only authentication. @@ -10305,6 +10481,188 @@ def __init__( self.next_link = None +class ManagedInstanceDtc(ProxyResource): + """SQL Managed Instance DTC. + + 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 dtc_enabled: Active status of managed instance DTC. + :vartype dtc_enabled: bool + :ivar security_settings: Security settings of managed instance DTC. + :vartype security_settings: ~azure.mgmt.sql.models.ManagedInstanceDtcSecuritySettings + :ivar external_dns_suffix_search_list: External dns suffix search list of managed instance DTC. + :vartype external_dns_suffix_search_list: list[str] + :ivar dtc_host_name_dns_suffix: Host name dns suffix of managed instance DTC. + :vartype dtc_host_name_dns_suffix: str + :ivar provisioning_state: Provisioning state of managed instance DTC. Known values are: + "Created", "InProgress", "Succeeded", "Failed", "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'dtc_host_name_dns_suffix': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'dtc_enabled': {'key': 'properties.dtcEnabled', 'type': 'bool'}, + 'security_settings': {'key': 'properties.securitySettings', 'type': 'ManagedInstanceDtcSecuritySettings'}, + 'external_dns_suffix_search_list': {'key': 'properties.externalDnsSuffixSearchList', 'type': '[str]'}, + 'dtc_host_name_dns_suffix': {'key': 'properties.dtcHostNameDnsSuffix', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + dtc_enabled: Optional[bool] = None, + security_settings: Optional["_models.ManagedInstanceDtcSecuritySettings"] = None, + external_dns_suffix_search_list: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword dtc_enabled: Active status of managed instance DTC. + :paramtype dtc_enabled: bool + :keyword security_settings: Security settings of managed instance DTC. + :paramtype security_settings: ~azure.mgmt.sql.models.ManagedInstanceDtcSecuritySettings + :keyword external_dns_suffix_search_list: External dns suffix search list of managed instance + DTC. + :paramtype external_dns_suffix_search_list: list[str] + """ + super(ManagedInstanceDtc, self).__init__(**kwargs) + self.dtc_enabled = dtc_enabled + self.security_settings = security_settings + self.external_dns_suffix_search_list = external_dns_suffix_search_list + self.dtc_host_name_dns_suffix = None + self.provisioning_state = None + + +class ManagedInstanceDtcListResult(msrest.serialization.Model): + """A list of managed instance's DTCs. + + 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.ManagedInstanceDtc] + :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': '[ManagedInstanceDtc]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ManagedInstanceDtcListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ManagedInstanceDtcSecuritySettings(msrest.serialization.Model): + """The Security Settings of managed instance DTC. + + :ivar transaction_manager_communication_settings: Transaction Manager communication settings of + managed instance DTC. + :vartype transaction_manager_communication_settings: + ~azure.mgmt.sql.models.ManagedInstanceDtcTransactionManagerCommunicationSettings + :ivar xa_transactions_enabled: Allow XA Transactions to managed instance DTC. + :vartype xa_transactions_enabled: bool + :ivar sna_lu6_point2_transactions_enabled: Allow SNA LU 6.2 to managed instance DTC. + :vartype sna_lu6_point2_transactions_enabled: bool + """ + + _attribute_map = { + 'transaction_manager_communication_settings': {'key': 'transactionManagerCommunicationSettings', 'type': 'ManagedInstanceDtcTransactionManagerCommunicationSettings'}, + 'xa_transactions_enabled': {'key': 'xaTransactionsEnabled', 'type': 'bool'}, + 'sna_lu6_point2_transactions_enabled': {'key': 'snaLu6point2TransactionsEnabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + transaction_manager_communication_settings: Optional["_models.ManagedInstanceDtcTransactionManagerCommunicationSettings"] = None, + xa_transactions_enabled: Optional[bool] = None, + sna_lu6_point2_transactions_enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword transaction_manager_communication_settings: Transaction Manager communication settings + of managed instance DTC. + :paramtype transaction_manager_communication_settings: + ~azure.mgmt.sql.models.ManagedInstanceDtcTransactionManagerCommunicationSettings + :keyword xa_transactions_enabled: Allow XA Transactions to managed instance DTC. + :paramtype xa_transactions_enabled: bool + :keyword sna_lu6_point2_transactions_enabled: Allow SNA LU 6.2 to managed instance DTC. + :paramtype sna_lu6_point2_transactions_enabled: bool + """ + super(ManagedInstanceDtcSecuritySettings, self).__init__(**kwargs) + self.transaction_manager_communication_settings = transaction_manager_communication_settings + self.xa_transactions_enabled = xa_transactions_enabled + self.sna_lu6_point2_transactions_enabled = sna_lu6_point2_transactions_enabled + + +class ManagedInstanceDtcTransactionManagerCommunicationSettings(msrest.serialization.Model): + """The Transaction Manager Communication Settings of managed instance DTC. + + :ivar allow_inbound_enabled: Allow Inbound traffic to managed instance DTC. + :vartype allow_inbound_enabled: bool + :ivar allow_outbound_enabled: Allow Outbound traffic of managed instance DTC. + :vartype allow_outbound_enabled: bool + :ivar authentication: Authentication type of managed instance DTC. + :vartype authentication: str + """ + + _attribute_map = { + 'allow_inbound_enabled': {'key': 'allowInboundEnabled', 'type': 'bool'}, + 'allow_outbound_enabled': {'key': 'allowOutboundEnabled', 'type': 'bool'}, + 'authentication': {'key': 'authentication', 'type': 'str'}, + } + + def __init__( + self, + *, + allow_inbound_enabled: Optional[bool] = None, + allow_outbound_enabled: Optional[bool] = None, + authentication: Optional[str] = None, + **kwargs + ): + """ + :keyword allow_inbound_enabled: Allow Inbound traffic to managed instance DTC. + :paramtype allow_inbound_enabled: bool + :keyword allow_outbound_enabled: Allow Outbound traffic of managed instance DTC. + :paramtype allow_outbound_enabled: bool + :keyword authentication: Authentication type of managed instance DTC. + :paramtype authentication: str + """ + super(ManagedInstanceDtcTransactionManagerCommunicationSettings, self).__init__(**kwargs) + self.allow_inbound_enabled = allow_inbound_enabled + self.allow_outbound_enabled = allow_outbound_enabled + self.authentication = authentication + + class ManagedInstanceEditionCapability(msrest.serialization.Model): """The managed server capability. 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 915d56476cef..48f6f16b20e1 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 @@ -392,6 +392,10 @@ class DnsRefreshConfigurationPropertiesStatus(str, Enum, metaclass=CaseInsensiti SUCCEEDED = "Succeeded" FAILED = "Failed" +class DtcName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + CURRENT = "current" + class ElasticPoolLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The license type to apply for this elastic pool. """ 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 3848df9ec3ed..37a7f5c2a8b0 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 @@ -131,6 +131,9 @@ from ._database_advanced_threat_protection_settings_operations import DatabaseAdvancedThreatProtectionSettingsOperations from ._server_advanced_threat_protection_settings_operations import ServerAdvancedThreatProtectionSettingsOperations from ._managed_server_dns_aliases_operations import ManagedServerDnsAliasesOperations +from ._managed_instance_dtcs_operations import ManagedInstanceDtcsOperations +from ._managed_database_advanced_threat_protection_settings_operations import ManagedDatabaseAdvancedThreatProtectionSettingsOperations +from ._managed_instance_advanced_threat_protection_settings_operations import ManagedInstanceAdvancedThreatProtectionSettingsOperations from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import @@ -261,6 +264,9 @@ 'DatabaseAdvancedThreatProtectionSettingsOperations', 'ServerAdvancedThreatProtectionSettingsOperations', 'ManagedServerDnsAliasesOperations', + 'ManagedInstanceDtcsOperations', + 'ManagedDatabaseAdvancedThreatProtectionSettingsOperations', + 'ManagedInstanceAdvancedThreatProtectionSettingsOperations', ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py new file mode 100644 index 000000000000..fc5ca492c847 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py @@ -0,0 +1,438 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +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 HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_database_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "advancedThreatProtectionName": _SERIALIZER.url("advanced_threat_protection_name", advanced_threat_protection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + subscription_id: str, + *, + json: Optional[_models.ManagedDatabaseAdvancedThreatProtection] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "advancedThreatProtectionName": _SERIALIZER.url("advanced_threat_protection_name", advanced_threat_protection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ManagedDatabaseAdvancedThreatProtectionSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_advanced_threat_protection_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + **kwargs: Any + ) -> Iterable[_models.ManagedDatabaseAdvancedThreatProtectionListResult]: + """Gets a list of managed database's Advanced Threat Protection states. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param database_name: The name of the database. + :type database_name: str + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedDatabaseAdvancedThreatProtectionListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedDatabaseAdvancedThreatProtectionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ManagedDatabaseAdvancedThreatProtectionListResult", 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( # pylint: disable=protected-access + 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/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Gets a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param database_name: The name of the database. + :type database_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedDatabaseAdvancedThreatProtection, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] + + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + + deserialized = self._deserialize('ManagedDatabaseAdvancedThreatProtection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + parameters: _models.ManagedDatabaseAdvancedThreatProtection, + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param database_name: The name of the database. + :type database_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedDatabaseAdvancedThreatProtection, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] + + _json = self._serialize.body(parameters, 'ManagedDatabaseAdvancedThreatProtection') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('ManagedDatabaseAdvancedThreatProtection', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedDatabaseAdvancedThreatProtection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore + diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py new file mode 100644 index 000000000000..2eacc898ea3a --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py @@ -0,0 +1,490 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "advancedThreatProtectionName": _SERIALIZER.url("advanced_threat_protection_name", advanced_threat_protection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + subscription_id: str, + *, + json: Optional[_models.ManagedInstanceAdvancedThreatProtection] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "advancedThreatProtectionName": _SERIALIZER.url("advanced_threat_protection_name", advanced_threat_protection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ManagedInstanceAdvancedThreatProtectionSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_advanced_threat_protection_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_instance( + self, + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable[_models.ManagedInstanceAdvancedThreatProtectionListResult]: + """Get the managed instance's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedInstanceAdvancedThreatProtectionListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceAdvancedThreatProtectionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_instance.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ManagedInstanceAdvancedThreatProtectionListResult", 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( # pylint: disable=protected-access + 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_instance.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + **kwargs: Any + ) -> _models.ManagedInstanceAdvancedThreatProtection: + """Get a managed instance's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedInstanceAdvancedThreatProtection, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceAdvancedThreatProtection] + + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + + deserialized = self._deserialize('ManagedInstanceAdvancedThreatProtection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + parameters: _models.ManagedInstanceAdvancedThreatProtection, + **kwargs: Any + ) -> Optional[_models.ManagedInstanceAdvancedThreatProtection]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ManagedInstanceAdvancedThreatProtection]] + + _json = self._serialize.body(parameters, 'ManagedInstanceAdvancedThreatProtection') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagedInstanceAdvancedThreatProtection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, "_models.AdvancedThreatProtectionName"], + parameters: _models.ManagedInstanceAdvancedThreatProtection, + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagedInstanceAdvancedThreatProtection + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceAdvancedThreatProtection] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ManagedInstanceAdvancedThreatProtection', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, 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 + ) + 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/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}"} # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py new file mode 100644 index 000000000000..0dbe0bfaf8e2 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py @@ -0,0 +1,484 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_managed_instance_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, "_models.DtcName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "dtcName": _SERIALIZER.url("dtc_name", dtc_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, "_models.DtcName"], + subscription_id: str, + *, + json: Optional[_models.ManagedInstanceDtc] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, 'str'), + "dtcName": _SERIALIZER.url("dtc_name", dtc_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ManagedInstanceDtcsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_dtcs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_managed_instance( + self, + resource_group_name: str, + managed_instance_name: str, + **kwargs: Any + ) -> Iterable[_models.ManagedInstanceDtcListResult]: + """Gets a list of managed instance DTC settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedInstanceDtcListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceDtcListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceDtcListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_managed_instance.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ManagedInstanceDtcListResult", 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( # pylint: disable=protected-access + 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_managed_instance.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, "_models.DtcName"], + **kwargs: Any + ) -> _models.ManagedInstanceDtc: + """Gets managed instance DTC settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedInstanceDtc, or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.ManagedInstanceDtc + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceDtc] + + + request = build_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + + deserialized = self._deserialize('ManagedInstanceDtc', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, "_models.DtcName"], + parameters: _models.ManagedInstanceDtc, + **kwargs: Any + ) -> _models.ManagedInstanceDtc: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceDtc] + + _json = self._serialize.body(parameters, 'ManagedInstanceDtc') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + + deserialized = self._deserialize('ManagedInstanceDtc', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, "_models.DtcName"], + parameters: _models.ManagedInstanceDtc, + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc + :keyword api_version: Api Version. Default value is "2022-02-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagedInstanceDtc or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-02-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagedInstanceDtc] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ManagedInstanceDtc', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, 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 + ) + 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/managedInstances/{managedInstanceName}/dtc/{dtcName}"} # type: ignore